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

Setup user on docker image to run it as no root #983

Merged
merged 1 commit into from
Sep 19, 2019
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
4 changes: 3 additions & 1 deletion pkg/scaffold/v2/dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:latest
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
USER nonroot:nonroot

ENTRYPOINT ["/manager"]
`
1 change: 1 addition & 0 deletions pkg/scaffold/v2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func main() {
Scheme: scheme,
MetricsBindAddress: metricsAddr,
LeaderElection: enableLeaderElection,
Port: 9443,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down
2 changes: 1 addition & 1 deletion pkg/scaffold/v2/webhook/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ metadata:
spec:
ports:
- port: 443
targetPort: 443
targetPort: 9443
selector:
control-plane: controller-manager
`
2 changes: 1 addition & 1 deletion pkg/scaffold/v2/webhook_manager_patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ spec:
containers:
- name: manager
ports:
- containerPort: 443
- containerPort: 9443
name: webhook-server
protocol: TCP
volumeMounts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
containers:
- name: manager
ports:
- containerPort: 443
- containerPort: 9443
name: webhook-server
protocol: TCP
volumeMounts:
Expand Down
2 changes: 1 addition & 1 deletion testdata/project-v2/config/webhook/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ metadata:
spec:
ports:
- port: 443
camilamacedo86 marked this conversation as resolved.
Show resolved Hide resolved
targetPort: 443
targetPort: 9443
selector:
control-plane: controller-manager
1 change: 1 addition & 0 deletions testdata/project-v2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func main() {
Scheme: scheme,
MetricsBindAddress: metricsAddr,
LeaderElection: enableLeaderElection,
Port: 9843,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down