Skip to content

Commit

Permalink
Merge pull request #983 from camilamacedo86/change-image
Browse files Browse the repository at this point in the history
Setup user on docker image to run it as no root
  • Loading branch information
k8s-ci-robot authored Sep 19, 2019
2 parents 76963b3 + 7af89cb commit c7a28a2
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 5 deletions.
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
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

0 comments on commit c7a28a2

Please sign in to comment.