Skip to content

Commit

Permalink
Improve security context for the k8s manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
dignajar committed Jun 23, 2021
1 parent 2c0b0ff commit b521c23
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions files/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def execute(self):
startReplicas = 1
startReplicasAnnotation = 'another-scheduler.io/start-replicas'
if startReplicasAnnotation in deployAnnotations:
self.logs.debug({'message': 'Start replicas defined by the user.', 'namespace': namespaceName, 'deployment': deployName, 'replicas': deployAnnotations[startReplicasAnnotation]})
self.logs.debug({'message': 'Replicas defined by the user for start.', 'namespace': namespaceName, 'deployment': deployName, 'replicas': deployAnnotations[startReplicasAnnotation]})
startReplicas = int(deployAnnotations[startReplicasAnnotation])

if deploy.spec.replicas != startReplicas:
Expand All @@ -80,7 +80,7 @@ def execute(self):
stopReplicas = 0
stopReplicasAnnotation = 'another-scheduler.io/stop-replicas'
if stopReplicasAnnotation in deployAnnotations:
self.logs.debug({'message': 'Stop replicas defined by the user.', 'namespace': namespaceName, 'deployment': deployName, 'replicas': deployAnnotations[stopReplicasAnnotation]})
self.logs.debug({'message': 'Replicas defined by the user for stop.', 'namespace': namespaceName, 'deployment': deployName, 'replicas': deployAnnotations[stopReplicasAnnotation]})
stopReplicas = int(deployAnnotations[stopReplicasAnnotation])

if deploy.spec.replicas != stopReplicas:
Expand Down
15 changes: 13 additions & 2 deletions kubernetes/full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ spec:
- configMapRef:
name: another-scheduler
securityContext:
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 10000
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsUser: 10001
capabilities:
drop:
- ALL
resources:
limits:
cpu: 300m
memory: 256Mi
requests:
cpu: 100m
memory: 128Mi

0 comments on commit b521c23

Please sign in to comment.