Skip to content

Commit

Permalink
fix(pvc): Add default fsGroup & remove empty-volume
Browse files Browse the repository at this point in the history
  • Loading branch information
yyvess committed Jan 31, 2024
1 parent ddbc1ce commit e61aa95
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 108 deletions.
16 changes: 1 addition & 15 deletions samples/minimum/ingress-pvc-values.cue
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,13 @@ values: {
storageClassName: "sc-kube-playground"
}

httpPort: 80
service: port: 80

resources: {
limits: {
cpu: "1000m"
memory: "768Mi"
}
}

securityContext: {
runAsUser: 0
runAsGroup: 0
runAsNonRoot: false
capabilities:
{
add: ["NET_BIND_SERVICE"]
drop: ["ALL"]
}
}

ingress: {
ingressClassName: "ing-kube-playground"
tls: [{
Expand All @@ -57,7 +43,7 @@ values: {
service: {
name: "keycloak-web"
port: {
number: 80
number: 8080
}
}}
}]
Expand Down
5 changes: 4 additions & 1 deletion templates/config.cue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ import (

// Pod optional settings.
podAnnotations?: {[string]: string}
podSecurityContext?: corev1.#PodSecurityContext
podSecurityContext: corev1.#PodSecurityContext | *{
fsGroup: 1000
fsGroupChangePolicy: "OnRootMismatch"
}
imagePullSecrets?: [...timoniv1.ObjectReference]
tolerations?: [...corev1.#Toleration]
affinity?: corev1.#Affinity
Expand Down
10 changes: 0 additions & 10 deletions templates/deployment.cue
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ import (
}
}
volumeMounts: [
{
name: "tmp"
mountPath: "/tmp"
},
if #highAvailability {
{
name: "cache"
Expand Down Expand Up @@ -181,12 +177,6 @@ import (
},
]
volumes: [
{
name: "tmp"
emptyDir: {
sizeLimit: "128Mi"
}
},
if #certSecretName != _|_ {
{
name: "certs"
Expand Down
8 changes: 3 additions & 5 deletions test/certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,6 @@ spec:
initialDelaySeconds: 30
periodSeconds: 15
volumeMounts:
- mountPath: /tmp
name: tmp
- mountPath: /opt/keycloak/conf
name: cache
readOnly: true
Expand All @@ -398,11 +396,11 @@ spec:
- mountPath: /jks
name: jks
readOnly: true
securityContext:
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
serviceAccountName: default
volumes:
- emptyDir:
sizeLimit: 128Mi
name: tmp
- name: certs
secret:
secretName: keycloak-cert
Expand Down
8 changes: 3 additions & 5 deletions test/external-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,17 @@ spec:
initialDelaySeconds: 30
periodSeconds: 15
volumeMounts:
- mountPath: /tmp
name: tmp
- mountPath: /certs
name: certs
readOnly: true
- mountPath: /jks
name: jks
readOnly: true
securityContext:
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
serviceAccountName: existing-sa
volumes:
- emptyDir:
sizeLimit: 128Mi
name: tmp
- name: certs
secret:
secretName: keycloak-cert
Expand Down
12 changes: 5 additions & 7 deletions test/http.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,10 @@ spec:
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 15
volumeMounts:
- mountPath: /tmp
name: tmp
volumeMounts: []
securityContext:
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
serviceAccountName: default
volumes:
- emptyDir:
sizeLimit: 128Mi
name: tmp
volumes: []
---
22 changes: 7 additions & 15 deletions test/ingress-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
ports:
- appProtocol: http
name: http
port: 80
port: 8080
protocol: TCP
targetPort: http
selector:
Expand Down Expand Up @@ -61,7 +61,7 @@ spec:
service:
name: keycloak-web
port:
number: 80
number: 8080
path: /
pathType: Prefix
tls:
Expand Down Expand Up @@ -103,8 +103,6 @@ spec:
value: local
- name: KC_DB
value: dev-file
- name: KC_HTTP_PORT
value: "80"
- name: KEYCLOAK_ADMIN
value: admin
- name: KEYCLOAK_ADMIN_PASSWORD
Expand All @@ -126,7 +124,7 @@ spec:
timeoutSeconds: 10
name: keycloak
ports:
- containerPort: 80
- containerPort: 8080
name: http
protocol: TCP
readinessProbe:
Expand All @@ -148,15 +146,11 @@ spec:
securityContext:
allowPrivilegeEscalation: false
capabilities:
add:
- NET_BIND_SERVICE
drop:
- ALL
privileged: false
readOnlyRootFilesystem: false
runAsGroup: 0
runAsNonRoot: false
runAsUser: 0
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
startupProbe:
Expand All @@ -168,15 +162,13 @@ spec:
initialDelaySeconds: 30
periodSeconds: 15
volumeMounts:
- mountPath: /tmp
name: tmp
- mountPath: /opt/keycloak/data/h2
name: data
securityContext:
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
serviceAccountName: default
volumes:
- emptyDir:
sizeLimit: 128Mi
name: tmp
- name: data
persistentVolumeClaim:
claimName: keycloak
Expand Down
12 changes: 5 additions & 7 deletions test/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,10 @@ spec:
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 15
volumeMounts:
- mountPath: /tmp
name: tmp
volumeMounts: []
securityContext:
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
serviceAccountName: default
volumes:
- emptyDir:
sizeLimit: 128Mi
name: tmp
volumes: []
---
12 changes: 5 additions & 7 deletions test/minimum.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,10 @@ spec:
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 15
volumeMounts:
- mountPath: /tmp
name: tmp
volumeMounts: []
securityContext:
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
serviceAccountName: default
volumes:
- emptyDir:
sizeLimit: 128Mi
name: tmp
volumes: []
---
12 changes: 5 additions & 7 deletions test/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,10 @@ spec:
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 15
volumeMounts:
- mountPath: /tmp
name: tmp
volumeMounts: []
securityContext:
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
serviceAccountName: default
volumes:
- emptyDir:
sizeLimit: 128Mi
name: tmp
volumes: []
---
8 changes: 3 additions & 5 deletions test/pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,14 @@ spec:
initialDelaySeconds: 30
periodSeconds: 15
volumeMounts:
- mountPath: /tmp
name: tmp
- mountPath: /opt/keycloak/conf
name: cache
readOnly: true
securityContext:
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
serviceAccountName: default
volumes:
- emptyDir:
sizeLimit: 128Mi
name: tmp
- configMap:
items:
- key: cache-ispn.xml
Expand Down
8 changes: 3 additions & 5 deletions test/postgres-istio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -405,19 +405,17 @@ spec:
initialDelaySeconds: 30
periodSeconds: 15
volumeMounts:
- mountPath: /tmp
name: tmp
- mountPath: /opt/keycloak/conf
name: cache
readOnly: true
- mountPath: /jks
name: jks
readOnly: true
securityContext:
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
serviceAccountName: default
volumes:
- emptyDir:
sizeLimit: 128Mi
name: tmp
- name: jks
secret:
secretName: keycloak-jks
Expand Down
8 changes: 3 additions & 5 deletions test/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,13 @@ spec:
initialDelaySeconds: 30
periodSeconds: 15
volumeMounts:
- mountPath: /tmp
name: tmp
- mountPath: /opt/keycloak/data/h2
name: data
securityContext:
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
serviceAccountName: default
volumes:
- emptyDir:
sizeLimit: 128Mi
name: tmp
- name: data
persistentVolumeClaim:
claimName: keycloak
Expand Down
12 changes: 5 additions & 7 deletions test/sa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,10 @@ spec:
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 15
volumeMounts:
- mountPath: /tmp
name: tmp
volumeMounts: []
securityContext:
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
serviceAccountName: custom-sa
volumes:
- emptyDir:
sizeLimit: 128Mi
name: tmp
volumes: []
---
12 changes: 5 additions & 7 deletions test/virtualservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,10 @@ spec:
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 15
volumeMounts:
- mountPath: /tmp
name: tmp
volumeMounts: []
securityContext:
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
serviceAccountName: default
volumes:
- emptyDir:
sizeLimit: 128Mi
name: tmp
volumes: []
---

0 comments on commit e61aa95

Please sign in to comment.