Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Add PSP support #389

Merged
merged 5 commits into from
Sep 19, 2018
Merged

Add PSP support #389

merged 5 commits into from
Sep 19, 2018

Conversation

andreas-kupries
Copy link
Contributor

@jandubois jandubois changed the base branch from master to develop September 6, 2018 22:18
Limited set of fixed names.
Reference variables in chart values.yml for user to configure.
No kube objects for undefined psp's.
Service account cloning in case of conflicting psp uses by the igroups using the account
PSP information is per-job, merged into a per-role value for use with service account
app/fissile_test.go Show resolved Hide resolved
model/roles.go Outdated

// GroupPolicy determines the name of the pod security policy
// governing the specified instance group.
func GroupPolicy(instanceGroup *InstanceGroup) string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this an exported function; it only seems to be called from within this file.

Also would prefer groupPodSecurityPolicy for consistency with other method names.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed with commit 30f483d

kube/pod.go Outdated
// This role requires a custom service account
block := helm.Block("")
if settings.CreateHelmChart {
block = helm.Block(authModeRBAC)
}
spec.Add("serviceAccountName", role.Run.ServiceAccount, block)
}

// Note: This group's PSP reference is not used, as it is not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what "group's PSP" means here. Aren't all PSPs on jobs and not on groups?

So not sure what this comment is supposed to be helping with here; it only leaves me more confused. Also seems to be the only reference to PSPs in this file. Why is it needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While PSP's are on jobs all the PSPs referenced by the jobs of an instance group are merged together into a single policy for the entire group. Because all the jobs currently still run in a single container/pod with a single PSP attached to it.

Will check if I can phrase it better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, checked. This comment is out of date. It harkens back to an interim state where the instance group structure actually had a PSP field. Then this moved to Jobs, and the IG's psp is computed (see groupPodSecurityPolicy), and then immediately moved to the associated service account.

Nothing is stored in the IG any longer.

I will remove this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in commit 273e933

kube/rbac.go Outdated
@@ -41,6 +41,31 @@ func NewRBACAccount(name string, account model.AuthAccount, settings ExportSetti
resources = append(resources, binding)
}

// Integrate a PSP, via ClusterRoleBinding to ClusterRole
if account.PodSecurityPolicy != "" && account.PodSecurityPolicy != "null" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolveSecurityPolicies always sets the value to either nonprivileged or privileged, so this conditional should always be true. How can the value be "" or "null" ?

Copy link
Contributor Author

@andreas-kupries andreas-kupries Sep 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "null" might be a leftover from some interim state. The ""-case might happen in tests which do not go through rSP. Will check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to be wrong. Only one test case affected, which explicitly has no PSP set. I will drop the conditions and remove that test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in commit 273e933

model/roles.go Outdated
// As service accounts can reference only one PSP the operation makes
// clones of the base SA as needed. Note that the clones reference the same
// roles as the base, and that the roles are not cloned.
func (m *RoleManifest) resolveSecurityPolicies() error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency this should include Pod, as in resolvePodSecurityPolicies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Will change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed with commit 30f483d

kube/rbac.go Outdated
@@ -76,3 +101,40 @@ func NewRBACRole(name string, role model.AuthRole, settings ExportSettings) (hel

return container.Sort(), nil
}

// authPSP creates a block condition checking for RBAC and the named PSP
func authPSP(psp string) helm.NodeModifier {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't like the function name (given that there is also authPSPRoleName).

Maybe authPSPCondition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like it. Will change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed with commit 30f483d

@jandubois jandubois merged commit 304c020 into develop Sep 19, 2018
@jandubois jandubois deleted the aku-9EmTR4JL-psp-support branch September 19, 2018 23:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants