Skip to content

Commit

Permalink
Added and change examples
Browse files Browse the repository at this point in the history
  • Loading branch information
WoozyMasta committed Feb 7, 2021
1 parent 32c863c commit d3b133d
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 7 deletions.
17 changes: 14 additions & 3 deletions deploy/cronjob-git-key.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,27 @@ spec:
env:
- name: MODE
value: "dump"
- name: DESTINATION_DIR
value: "/data/dump"
- name: GIT_PUSH
value: "true"
- name: GIT_BRANCH
value: "k8s-cluster"
value: "master"
- name: GIT_COMMIT_USER
value: "Kube Dump"
- name: GIT_COMMIT_EMAIL
value: "kube@dump.local"
- name: GIT_REMOTE_URL
value: "git@corp-gitlab.com:devops/cluster-bkp.git"
volumeMounts:
- name: data
mountPath: /data
- name: key
mountPath: /root/.ssh/id_ed25519
subPath: id_ed25519
readOnly: true
- name: key-pub
mountPath: /root/.ssh/id_ed25519.pub
subPath: id_ed25519.pub
readOnly: true
resources:
limits:
cpu: 500m
Expand All @@ -47,15 +53,20 @@ spec:
memory: 100Mi
restartPolicy: OnFailure
volumes:
- name: data
persistentVolumeClaim:
claimName: kube-dump
- name: key
secret:
secretName: kube-dump-key
items:
- key: kube-dump
path: id_ed25519
mode: 0600
- name: key-pub
secret:
secretName: kube-dump-key
items:
- key: kube-dump.pub
path: id_ed25519.pub
mode: 0600
62 changes: 62 additions & 0 deletions deploy/pod-sa-git-key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
apiVersion: v1
kind: Pod
metadata:
labels:
app: kube-dump
name: kube-dump
namespace: kube-dump
spec:
serviceAccountName: kube-dump
containers:
- name: kube-dump
image: woozymasta/kube-dump:1.0
imagePullPolicy: IfNotPresent
command: ["/bin/bash", "-c", "--"]
args: ["while true; do sleep 60; done;"]
env:
- name: MODE
value: "dump"
- name: DESTINATION_DIR
value: "/data/dump"
- name: GIT_PUSH
value: "true"
- name: GIT_BRANCH
value: "master"
- name: GIT_REMOTE_URL
value: "git@corp-gitlab.com:devops/cluster-bkp.git"
volumeMounts:
- name: data
mountPath: /data
- name: key
mountPath: /root/.ssh/id_ed25519
subPath: id_ed25519
- name: key-pub
mountPath: /root/.ssh/id_ed25519.pub
subPath: id_ed25519.pub
resources:
limits:
cpu: 500m
memory: 200Mi
requests:
cpu: 200m
memory: 100Mi
restartPolicy: OnFailure
volumes:
- name: data
persistentVolumeClaim:
claimName: kube-dump
- name: key
secret:
secretName: kube-dump-key
items:
- key: kube-dump
path: id_ed25519
mode: 0600
- name: key-pub
secret:
secretName: kube-dump-key
items:
- key: kube-dump.pub
path: id_ed25519.pub
mode: 0600
6 changes: 3 additions & 3 deletions deploy/pod-sa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ spec:
imagePullPolicy: IfNotPresent
command: ["/bin/bash", "-c", "--"]
args: ["while true; do sleep 60; done;"]
volumeMounts:
- name: data
mountPath: /data
resources:
limits:
cpu: 500m
memory: 200Mi
requests:
cpu: 200m
memory: 100Mi
volumeMounts:
- name: data
mountPath: /data
restartPolicy: OnFailure
volumes:
- name: data
Expand Down
9 changes: 8 additions & 1 deletion docs/conjob.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ Show public ssh key and add to repository deployment keys with write access.
cat ./.ssh/kube-dump.pub
```

Create pvc for store data such as cache

```shell
kubectl apply -n kube-dump -f deploy/pvc.yaml
```

Create secret with private ssh key

```shell
Expand All @@ -82,7 +88,8 @@ kubectl -n kube-dump create secret generic kube-dump-key \
--from-file=./.ssh/kube-dump.pub
```

And apply the cron job manifest:
And apply the cron job manifest,
previously you could set up environment variables

```shell
kubectl apply -n kube-dump -f deploy/cronjob-git-key.yaml
Expand Down
16 changes: 16 additions & 0 deletions docs/pod.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,19 @@ kubectl apply -n kube-dump -f deploy/cluster-role-view.yaml
kubectl apply -n kube-dump -f deploy/pvc.yaml
kubectl apply -n kube-dump -f deploy/pod-kubeconfig.yaml
```

## Deploy with serviceaccount, ssh key and volume

```shell
mkdir -p ./.ssh
chmod 0700 ./.ssh
ssh-keygen -t ed25519 -C "kube-dump" -f ./.ssh/kube-dump
cat ./.ssh/kube-dump.pub
kubectl -n kube-dump create secret generic kube-dump-key \
--from-file=./.ssh/kube-dump \
--from-file=./.ssh/kube-dump.pub
kubectl create ns kube-dump
kubectl apply -n kube-dump -f deploy/cluster-role-view.yaml
kubectl apply -n kube-dump -f deploy/pvc.yaml
kubectl apply -n kube-dump -f deploy/pod-sa-git-key.yaml
```

0 comments on commit d3b133d

Please sign in to comment.