Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ specify nonroot uid for manager (v3+ only) #1635

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,17 @@ spec:
labels:
control-plane: controller-manager
spec:
securityContext:
runAsUser: 65532
containers:
- command:
- /manager
args:
- --enable-leader-election
image: {{ .Image }}
name: manager
securityContext:
allowPrivilegeEscalation: false
resources:
limits:
cpu: 100m
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugin/v3/scaffolds/internal/templates/dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
USER nonroot:nonroot
USER 65532:65532

ENTRYPOINT ["/manager"]
`
2 changes: 1 addition & 1 deletion testdata/project-v3-addon/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
USER nonroot:nonroot
USER 65532:65532

ENTRYPOINT ["/manager"]
4 changes: 4 additions & 0 deletions testdata/project-v3-addon/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ spec:
labels:
control-plane: controller-manager
spec:
securityContext:
runAsUser: 65532
containers:
- command:
Copy link
Member

Choose a reason for hiding this comment

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

Could we add in the manifests allowPrivilegeEscalation: false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

- /manager
args:
- --enable-leader-election
image: controller:latest
name: manager
securityContext:
allowPrivilegeEscalation: false
resources:
limits:
cpu: 100m
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v3-multigroup/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
USER nonroot:nonroot
USER 65532:65532

ENTRYPOINT ["/manager"]
4 changes: 4 additions & 0 deletions testdata/project-v3-multigroup/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ spec:
labels:
control-plane: controller-manager
spec:
securityContext:
runAsUser: 65532
containers:
- command:
- /manager
args:
- --enable-leader-election
image: controller:latest
name: manager
securityContext:
allowPrivilegeEscalation: false
resources:
limits:
cpu: 100m
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
USER nonroot:nonroot
USER 65532:65532

ENTRYPOINT ["/manager"]
4 changes: 4 additions & 0 deletions testdata/project-v3/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ spec:
labels:
control-plane: controller-manager
spec:
securityContext:
runAsUser: 65532
containers:
- command:
- /manager
args:
- --enable-leader-election
image: controller:latest
name: manager
securityContext:
allowPrivilegeEscalation: false
resources:
limits:
cpu: 100m
Expand Down