@@ -23,6 +23,7 @@ compose.yaml: score/score.yaml .score-compose/state.yaml Makefile
23
23
score-compose generate score/score.yaml \
24
24
--build ' ${CONTAINER_NAME}={"context":"app/","tags":["${CONTAINER_IMAGE}"]}' \
25
25
--override-property containers.${CONTAINER_NAME} .variables.MESSAGE=" Hello, Compose!"
26
+ echo ' {"services":{"${WORKLOAD_NAME}-${CONTAINER_NAME}":{"read_only":"true","user":"65532","cap_drop":["ALL"]}}}' | yq e -P > compose.override.yaml
26
27
27
28
# # Generate a compose.yaml file from the score spec and launch it.
28
29
.PHONY : compose-up
@@ -47,7 +48,10 @@ compose-down:
47
48
manifests.yaml : score/score.yaml .score-k8s/state.yaml Makefile
48
49
score-k8s generate score/score.yaml \
49
50
--image ${CONTAINER_IMAGE} \
50
- --override-property containers.${CONTAINER_NAME} .variables.MESSAGE=" Hello, Kubernetes!"
51
+ --override-property containers.${CONTAINER_NAME} .variables.MESSAGE=" Hello, Kubernetes!" \
52
+ --patch-manifests ' Deployment/*/spec.template.spec.automountServiceAccountToken=false' \
53
+ --patch-manifests ' Deployment/*/spec.template.spec.securityContext={"fsGroup":65532,"runAsGroup":65532,"runAsNonRoot":true,"runAsUser":65532,"seccompProfile":{"type":"RuntimeDefault"}}'
54
+ echo ' {"spec":{"template":{"spec":{"containers":[{"name":"${CONTAINER_NAME}","securityContext":{"allowPrivilegeEscalation":false,"privileged": false,"readOnlyRootFilesystem": true,"capabilities":{"drop":["ALL"]}}}]}}}}' > deployment-patch.yaml
51
55
52
56
# # Create a local Kind cluster.
53
57
.PHONY : kind-create-cluster
@@ -66,6 +70,10 @@ k8s-up: manifests.yaml
66
70
kubectl apply \
67
71
-f manifests.yaml \
68
72
-n ${NAMESPACE}
73
+ kubectl patch \
74
+ deployment ${WORKLOAD_NAME} \
75
+ --patch-file deployment-patch.yaml \
76
+ -n ${NAMESPACE}
69
77
kubectl wait deployments/${WORKLOAD_NAME} \
70
78
-n ${NAMESPACE} \
71
79
--for condition=Available \
0 commit comments