Last active
February 16, 2017 05:08
-
-
Save groundnuty/3c38911676268210c10acb9db424e383 to your computer and use it in GitHub Desktop.
ordered sets tests
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
# It's not possible to declare a pod with path to a file, a content would have to be: cat file | base64 | |
# ssh-keyscan github.com >> /home/ubuntu/yamls/known_hosts | |
# kubectl create secret generic github-test-repo-deploy-key --from-file=id_rsa=/root/.ssh/id_rsa --from-file=id_rsa.pub=/root/.ssh/id_rsa.pub --from-file=known_hosts=/home/ubuntu/yamls/known_hosts | |
# | |
# kubectl create secret docker-registry docker-onedata-org-morzech --docker-username=xxx --docker-password=xxx --docker-email=xxx --docker-server=docker.onedata.org | |
# | |
# NAME="docker.onedata.org/morzech/data-container:$(date +'%Y-%m-%d-%H-%M-%S')-r$RANDOM" ; docker build /dcv -q -t "$NAME" ; docker push "$NAME" | |
#apiVersion: v1 | |
#kind: Secret | |
#metadata: | |
# name: wordpress-secrets | |
#type: Opaque | |
#data: | |
# username: d293IHlvdSBkZWNvZGVkIGl0 | |
# password: Z29vZCBmb3IgeW91 | |
# host: bm90aGluZyBqdWljeSB0aG91Z2g= | |
--- | |
apiVersion: apps/v1beta1 | |
kind: StatefulSet | |
metadata: | |
name: ordered-set | |
spec: | |
serviceName: "order" | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: order | |
annotations: | |
# the rm command uses regexps from | |
# http://serverfault.com/questions/47933/how-to-delete-all-hidden-files-and-directories-using-bash | |
pod.beta.kubernetes.io/init-containers: '[ | |
{ | |
"name": "git-clone1", | |
"image": "boomtownroi/git", | |
"command": [ | |
"sh", "-c", | |
"git clone https://github.com/groundnuty/data-container.git /dcv/" | |
], | |
"volumeMounts": [ | |
{ | |
"mountPath": "/dcv/", | |
"name": "dcv" | |
} | |
] | |
}, | |
{ | |
"name": "data-container", | |
"image": "docker.onedata.org/morzech/nginx-data-container:overwrite", | |
"command": [ | |
"sh", "-c", | |
"ls -laR / ; cp -r /data/* /shared/" | |
], | |
"imagePullPolicy": "Always", | |
"volumeMounts": [ | |
{ | |
"mountPath": "/shared/", | |
"name": "shared" | |
} | |
] | |
} | |
]' | |
spec: | |
nodeSelector: | |
kubernetes.io/hostname: ks1 | |
terminationGracePeriodSeconds: 120 | |
volumes: | |
- name: dcv | |
emptyDir: {} | |
- name: monitor | |
emptyDir: {} | |
- name: shared | |
emptyDir: {} | |
- name: docker-onedata-org-morzech-vol | |
secret: | |
secretName: docker-onedata-org-morzech | |
imagePullSecrets: | |
- name: docker-onedata-org-morzech | |
containers: | |
- name: first | |
image: nginx | |
volumeMounts: | |
- mountPath: /usr/share/nginx/html/ | |
name: shared | |
- mountPath: /monitor/ | |
name: monitor | |
lifecycle: | |
postStart: | |
exec: | |
command: | |
- "sh" | |
- "-c" | |
- > | |
NAME="nginx:$(date +'%Y-%m-%d-%H-%M-%S')-r$RANDOM" ; | |
echo "$NAME" >> /usr/share/nginx/html/index.html ; | |
echo 1 > /monitor/nginx-exit ; | |
- name: docker-engine | |
image: docker:1.13-dind | |
securityContext: | |
privileged: true | |
volumeMounts: | |
- mountPath: /monitor/ | |
name: monitor | |
lifecycle: | |
preStop: | |
exec: | |
command: | |
- "sh" | |
- "-c" | |
- > | |
while [ ! -f /monitor/docker-engine-exit ] ; do sleep 2 ; done ; | |
- name: docker-persistence-commiter | |
image: docker:1.13 | |
args: | |
- "sh" | |
- "-c" | |
- > | |
while [ ! -f /monitor/docker-engine-exit ] ; do sleep 2 ; done ; | |
lifecycle: | |
preStop: | |
exec: | |
command: | |
- "sh" | |
- "-c" | |
- > | |
export DOCKER_HOST='tcp://localhost:2375' ; | |
while [ ! -f /monitor/nginx-exit ] ; do sleep 2 ; done ; | |
while ! echo exit | nc localhost 2375; do sleep 3; done; | |
cp /dcv/Dockerfile /shared/ ; | |
echo "Dockerfile" > /shared/.dockerignore ; | |
NAME="docker.onedata.org/morzech/nginx-data-container:$(date +'%Y-%m-%d-%H-%M-%S')-r$RANDOM" ; | |
cd /shared ; | |
echo "preStop $NAME" >> index.html ; | |
NAME="docker.onedata.org/morzech/nginx-data-container:overwrite" ; | |
docker build /shared/ -q -t "$NAME" ; docker push "$NAME" ; | |
echo 1 > /monitor/docker-engine-exit ; | |
volumeMounts: | |
- mountPath: /shared/ | |
name: shared | |
- mountPath: /monitor/ | |
name: monitor | |
- mountPath: /dcv/ | |
name: dcv | |
- mountPath: /root/ | |
name: docker-onedata-org-morzech-vol |
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
# It's not possible to declare a pod with path to a file, a content would have to be: cat file | base64 | |
# ssh-keyscan github.com >> /home/ubuntu/yamls/known_hosts | |
# kubectl create secret generic github-test-repo-deploy-key --from-file=id_rsa=/root/.ssh/id_rsa --from-file=id_rsa.pub=/root/.ssh/id_rsa.pub --from-file=known_hosts=/home/ubuntu/yamls/known_hosts | |
# | |
# kubectl create secret docker-registry docker-onedata-org-morzech --docker-username=xxx --docker-password=xxx --docker-email=xxx --docker-server=docker.onedata.org | |
# | |
# NAME="docker.onedata.org/morzech/data-container:$(date +'%Y-%m-%d-%H-%M-%S')-r$RANDOM" ; docker build /dcv -q -t "$NAME" ; docker push "$NAME" | |
#apiVersion: v1 | |
#kind: Secret | |
#metadata: | |
# name: wordpress-secrets | |
#type: Opaque | |
#data: | |
# username: d293IHlvdSBkZWNvZGVkIGl0 | |
# password: Z29vZCBmb3IgeW91 | |
# host: bm90aGluZyBqdWljeSB0aG91Z2g= | |
--- | |
apiVersion: apps/v1beta1 | |
kind: StatefulSet | |
metadata: | |
name: ordered-set | |
spec: | |
serviceName: "order" | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: order | |
annotations: | |
# the rm command uses regexps from | |
# http://serverfault.com/questions/47933/how-to-delete-all-hidden-files-and-directories-using-bash | |
pod.beta.kubernetes.io/init-containers: '[ | |
{ | |
"name": "init", | |
"image": "bash", | |
"command": [ | |
"bash", "-c", | |
"rm -rf /data/* /data/.[^.] /data/.??*" | |
], | |
"volumeMounts": [ | |
{ | |
"mountPath": "/data/", | |
"name": "git" | |
} | |
] | |
}, | |
{ | |
"name": "git-clone", | |
"image": "boomtownroi/git", | |
"env": [ | |
{ | |
"name": "GIT_SSH_COMMAND", | |
"value": "ssh -i /root/.ssh/id_rsa" | |
} | |
], | |
"command": [ | |
"sh", "-c", | |
"git clone git@github.com:groundnuty/beginner-html-site-scripted.git /data/" | |
], | |
"volumeMounts": [ | |
{ | |
"mountPath": "/data/", | |
"name": "git" | |
}, | |
{ | |
"mountPath": "/root/.ssh/", | |
"name": "ssh-key" | |
} | |
] | |
}, | |
{ | |
"name": "git-clone1", | |
"image": "boomtownroi/git", | |
"command": [ | |
"sh", "-c", | |
"git clone https://github.com/groundnuty/data-container.git /dcv/" | |
], | |
"volumeMounts": [ | |
{ | |
"mountPath": "/dcv/", | |
"name": "dcv" | |
} | |
] | |
}, | |
{ | |
"name": "data-container", | |
"image": "docker.onedata.org/morzech/data-container:overwrite", | |
"command": [ | |
"sh", "-c", | |
"ls -laR / ; cp -r oz_config /shared/ ; cp -r op_config /shared/ ; cp -r op_data /shared/" | |
], | |
"volumeMounts": [ | |
{ | |
"mountPath": "/shared/", | |
"name": "shared" | |
} | |
] | |
} | |
]' | |
spec: | |
nodeSelector: | |
kubernetes.io/hostname: ks1 | |
terminationGracePeriodSeconds: 2 | |
volumes: | |
- name: git | |
hostPath: | |
# directory location on host | |
path: /tmp/data | |
- name: dcv | |
emptyDir: {} | |
- name: shared | |
emptyDir: {} | |
- name: ssh-key | |
secret: | |
# directory location on host | |
secretName: github-test-repo-deploy-key | |
- name: ssh-key | |
secret: | |
# directory location on host | |
secretName: github-test-repo-deploy-key | |
#defaultMode: 0400 # as for the moment I included known_hosts as well, lets specify modes for all files individually | |
items: | |
- key: id_rsa | |
path: id_rsa | |
mode: 0400 | |
- key: id_rsa.pub | |
path: id_rsa.pub | |
mode: 0400 | |
- key: known_hosts | |
path: known_hosts | |
mode: 0600 | |
- name: docker-onedata-org-morzech-vol | |
secret: | |
secretName: docker-onedata-org-morzech | |
imagePullSecrets: | |
- name: docker-onedata-org-morzech | |
containers: | |
- name: first | |
image: boomtownroi/git | |
env: | |
- name: MESSAGE | |
value: "first executing" | |
- name: GIT_SSH_COMMAND | |
value: "ssh -i /root/.ssh/id_rsa" | |
command: ["/bin/sh","-c"] | |
args: | |
- > | |
echo $(hostname -f) $MESSAGE $(date) >> /data/index.html ; | |
sleep 3600 ; | |
exit 0 | |
lifecycle: | |
postStart: # this is executed after args command in the container | |
exec: | |
command: | |
- "sh" | |
- "-c" | |
- > | |
echo -n "first postStart " >> /data/index.html | |
preStop: | |
exec: | |
command: | |
- "sh" | |
- "-c" | |
- > | |
echo -n "first preStop " >> /data/index.html; | |
cd /data ; | |
git add -A ; | |
git commit -am "auto commit" ; | |
git push ; | |
volumeMounts: | |
- mountPath: /dcv/ | |
name: dcv | |
- mountPath: /data/ | |
name: git | |
- mountPath: /root/.ssh/ | |
#readOnly: true # as for the moment I included known_hosts as well, lets keep it rw | |
name: ssh-key | |
- name: docker-engine | |
image: docker:1.13-dind | |
securityContext: | |
privileged: true | |
- name: docker-persistence-commiter | |
image: docker:1.13 | |
args: # can't use github lin in docker build, because this image does not have git command installed | |
- "sh" | |
- "-c" | |
- > | |
export DOCKER_HOST='tcp://localhost:2375' ; | |
cp /dcv/Dockerfile /shared/ ; | |
NAME="docker.onedata.org/morzech/data-container:$(date +'%Y-%m-%d-%H-%M-%S')-r$RANDOM" ; | |
cd shared ; | |
echo "$NAME" >> oz_config/data ; | |
echo "$NAME" >> op_config/data ; | |
echo "$NAME" >> op_data/data ; | |
NAME="docker.onedata.org/morzech/data-container:overwrite" ; | |
docker build /shared/ -q -t "$NAME" ; docker push "$NAME" ; | |
sleep 3600 ; | |
# lifecycle: | |
# preStop: | |
# exec: | |
# command: | |
# - "sh" | |
# - "-c" | |
# - > | |
# export DOCKER_HOST='tcp://localhost:2375' ; | |
# cp /dcv/Dockerfile /shared/ ; | |
# NAME="docker.onedata.org/morzech/data-container:$(date +'%Y-%m-%d-%H-%M-%S')-r$RANDOM" ; | |
# cd shared ; | |
# echo "$NAME" >> oz_config/data ; | |
# echo "$NAME" >> op_config/data ; | |
# echo "$NAME" >> op_data/data ; | |
# NAME="docker.onedata.org/morzech/data-container:overwrite" ; | |
# docker build /shared/ -q -t "$NAME" ; docker push "$NAME" ; | |
volumeMounts: | |
- mountPath: /shared/ | |
name: shared | |
- mountPath: /dcv/ | |
name: dcv | |
- mountPath: /root/ | |
name: docker-onedata-org-morzech-vol |
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
# It's not possible to declare a pod with path to a file, a content would have to be: cat file | base64 | |
# ssh-keyscan github.com >> /home/ubuntu/yamls/known_hosts | |
# kubectl create secret generic github-test-repo-deploy-key --from-file=id_rsa=/root/.ssh/id_rsa --from-file=id_rsa.pub=/root/.ssh/id_rsa.pub --from-file=known_hosts=/home/ubuntu/yamls/known_hosts | |
# | |
#apiVersion: v1 | |
#kind: Secret | |
#metadata: | |
# name: wordpress-secrets | |
#type: Opaque | |
#data: | |
# username: d293IHlvdSBkZWNvZGVkIGl0 | |
# password: Z29vZCBmb3IgeW91 | |
# host: bm90aGluZyBqdWljeSB0aG91Z2g= | |
--- | |
apiVersion: apps/v1beta1 | |
kind: StatefulSet | |
metadata: | |
name: ordered-set | |
spec: | |
serviceName: "order" | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: order | |
annotations: | |
# the rm command uses regexps from | |
# http://serverfault.com/questions/47933/how-to-delete-all-hidden-files-and-directories-using-bash | |
pod.beta.kubernetes.io/init-containers: '[ | |
{ | |
"name": "init", | |
"image": "bash", | |
"command": [ | |
"bash", "-c", | |
"rm -rf /data/* /data/.[^.] /data/.??*" | |
], | |
"volumeMounts": [ | |
{ | |
"mountPath": "/data/", | |
"name": "git" | |
} | |
] | |
}, | |
{ | |
"name": "git-clone", | |
"image": "boomtownroi/git", | |
"env": [ | |
{ | |
"name": "GIT_SSH_COMMAND", | |
"value": "ssh -i /root/.ssh/id_rsa" | |
} | |
], | |
"command": [ | |
"sh", "-c", | |
"git clone git@github.com:groundnuty/beginner-html-site-scripted.git /data/" | |
], | |
"volumeMounts": [ | |
{ | |
"mountPath": "/data/", | |
"name": "git" | |
}, | |
{ | |
"mountPath": "/root/.ssh/", | |
"name": "ssh-key" | |
} | |
] | |
} | |
]' | |
spec: | |
nodeSelector: | |
kubernetes.io/hostname: ks1 | |
terminationGracePeriodSeconds: 2 | |
volumes: | |
- name: git | |
hostPath: | |
# directory location on host | |
path: /tmp/data | |
- name: ssh-key | |
secret: | |
# directory location on host | |
secretName: github-test-repo-deploy-key | |
#defaultMode: 0400 # as for the moment I included known_hosts as well, lets specify modes for all files individually | |
items: | |
- key: id_rsa | |
path: id_rsa | |
mode: 0400 | |
- key: id_rsa.pub | |
path: id_rsa.pub | |
mode: 0400 | |
- key: known_hosts | |
path: known_hosts | |
mode: 0600 | |
containers: | |
- name: first | |
image: boomtownroi/git | |
env: | |
- name: MESSAGE | |
value: "first executing" | |
- name: GIT_SSH_COMMAND | |
value: "ssh -i /root/.ssh/id_rsa" | |
command: ["/bin/sh","-c"] | |
args: | |
- > | |
echo $(hostname -f) $MESSAGE $(date) >> /data/index.html ; | |
sleep 3600 ; | |
exit 0 | |
lifecycle: | |
postStart: # this is executed after args command in the container | |
exec: | |
command: | |
- "sh" | |
- "-c" | |
- > | |
echo -n "first postStart " >> /data/index.html | |
preStop: | |
exec: | |
command: | |
- "sh" | |
- "-c" | |
- > | |
echo -n "first preStop " >> /data/index.html; | |
cd /data ; | |
git add -A ; | |
git commit -am "auto commit" ; | |
git push ; | |
volumeMounts: | |
- mountPath: /data/ | |
name: git | |
- mountPath: /root/.ssh/ | |
#readOnly: true # as for the moment I included known_hosts as well, lets keep it rw | |
name: ssh-key |
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
--- | |
apiVersion: apps/v1beta1 | |
kind: StatefulSet | |
metadata: | |
name: ordered-set | |
spec: | |
serviceName: "order" | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: order | |
annotations: | |
pod.beta.kubernetes.io/init-containers: '[ | |
{ | |
"name": "install", | |
"image": "bash", | |
"command": ["sh", "-c", "echo init-container >> /data/file"], | |
"volumeMounts": [ | |
{ | |
"name": "test-volume", | |
"mountPath": "/data/" | |
} | |
] | |
} | |
]' | |
spec: | |
nodeSelector: | |
kubernetes.io/hostname: ks1 | |
terminationGracePeriodSeconds: 2 | |
volumes: | |
- name: test-volume | |
hostPath: | |
# directory location on host | |
path: /tmp/data | |
containers: | |
- name: first | |
image: bash | |
env: | |
- name: MESSAGE | |
value: "first executing" | |
command: ["/usr/local/bin/bash","-c"] | |
args: | |
- > | |
echo $(hostname -f) $MESSAGE $(date) >> /data/file ; | |
sleep 20 ; | |
exit 0 | |
lifecycle: | |
postStart: # this is executed after args command in the container | |
exec: | |
command: | |
- "sh" | |
- "-c" | |
- > | |
echo -n "first postStart " >> /data/file | |
preStop: | |
exec: | |
command: | |
- "sh" | |
- "-c" | |
- > | |
echo -n "first preStop " >> /data/file | |
volumeMounts: | |
- mountPath: /data/ | |
name: test-volume |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment