Created
March 9, 2018 19:54
-
-
Save tallclair/849601a16cebeee581ef2be50c351841 to your computer and use it in GitHub Desktop.
More secure GitRepo volumes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of using an InitContainer in place of a GitRepo volume. | |
# Unilke GitRepo volumes, this approach runs the git command in a container, | |
# with the associated hardening. | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: git-repo-demo | |
annotations: | |
seccomp.security.alpha.kubernetes.io/pod: 'docker/default' | |
spec: | |
initContainers: | |
# This container clones the desired git repo to the EmptyDir volume. | |
- name: git-clone | |
image: alpine/git # Any image with git will do | |
args: | |
- clone | |
- --single-branch | |
- -- | |
- https://github.com/kubernetes/kubernetes # Your repo | |
- /repo # Put it in the volume | |
securityContext: | |
runAsUser: 1 # Any non-root user will do. Match to the workload. | |
allowPrivilegeEscalation: false | |
readOnlyRootFilesystem: true | |
volumeMounts: | |
- name: git-repo | |
mountPath: /repo | |
containers: | |
# Replace with your actual workload. | |
- name: busybox | |
image: busybox | |
args: ['sleep', '100000'] # Do nothing | |
volumeMounts: | |
- name: git-repo | |
mountPath: /repo | |
volumes: | |
- name: git-repo | |
emptyDir: {} |
Thanks! It is so helpful
Actually you could replace the
args: ['sleep', '100000']
by:
args: ['tail','-f','/dev/null']
Busybox sleep does not have the sleep forever argument, so that´s a replacement...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is waht I really wanted!! Thanks! Could you elaborate about
git args
andsecurityContext
please..? Or, give a reference about it?