Skip to content

Commit 7f4bf38

Browse files
author
fmeng
committed
etcd backup and tekton
1 parent ce42936 commit 7f4bf38

7 files changed

+190
-0
lines changed

etcd/install-ha-etcd.MD

+13
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,16 @@ mv certs /tmp/etcd-certs
3939
./start-infra1.sh
4040
./start-infra0.sh
4141
```
42+
### backup
43+
```
44+
etcdctl --endpoints https://127.0.0.1:3379 --cert /tmp/etcd-certs/certs/127.0.0.1.pem --key /tmp/etcd-certs/certs/127.0.0.1-key.pem --cacert /tmp/etcd-certs/certs/ca.pem snapshot save snapshot.db
45+
```
46+
### delete data
47+
```
48+
kill process of infra0 infra1 infra2
49+
```
50+
```
51+
rm -rf /tmp/etcd
52+
```
53+
### restore
54+

etcd/restore.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export ETCDCTL_API=3
2+
etcdctl snapshot restore snapshot.db \
3+
--name infra0 \
4+
--data-dir=/tmp/etcd/infra0 \
5+
--initial-cluster infra0=http://127.0.0.1:3380,infra1=http://127.0.0.1:4380,infra2=http://127.0.0.1:5380 \
6+
--initial-cluster-token etcd-cluster-1 \
7+
--initial-advertise-peer-urls http://127.0.0.1:3380
8+
9+
etcdctl snapshot restore snapshot.db \
10+
--name infra1 \
11+
--data-dir=/tmp/etcd/infra1 \
12+
--initial-cluster infra0=http://127.0.0.1:3380,infra1=http://127.0.0.1:4380,infra2=http://127.0.0.1:5380 \
13+
--initial-cluster-token etcd-cluster-1 \
14+
--initial-advertise-peer-urls http://127.0.0.1:4380
15+
16+
etcdctl snapshot restore snapshot.db \
17+
--name infra2 \
18+
--data-dir=/tmp/etcd/infra2 \
19+
--initial-cluster infra0=http://127.0.0.1:3380,infra1=http://127.0.0.1:4380,infra2=http://127.0.0.1:5380 \
20+
--initial-cluster-token etcd-cluster-1 \
21+
--initial-advertise-peer-urls http://127.0.0.1:5380

tekton/git-tasks.yaml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apiVersion: tekton.dev/v1beta1
2+
kind: Task
3+
metadata:
4+
name: github-build
5+
spec:
6+
params:
7+
- name: IMAGE
8+
description: Name (reference) of the image to build.
9+
default: cncamp/httpserver:v1.0
10+
- name: DOCKERFILE
11+
description: Path to the Dockerfile to build.
12+
default: ./httpserver/Dockerfile
13+
resources:
14+
inputs:
15+
- name: repo
16+
type: git
17+
steps:
18+
- name: gthub-build
19+
image: cncamp/executor
20+
workingDir: /workspace/repo
21+
args:
22+
- "--dockerfile=./httpserver/Dockerfile"
23+
- "--context=./httpserver"
24+
- "--destination=cncamp/httpserver:v1.0"
25+
workspaces:
26+
- name: dockerconfig
27+
description: Includes a docker `config.json`
28+
optional: true
29+
mountPath: /kaniko/.docker
30+
---
31+
apiVersion: tekton.dev/v1beta1
32+
kind: TaskRun
33+
metadata:
34+
name: github-build
35+
spec:
36+
serviceAccountName: cncamp-sa
37+
taskRef:
38+
name: github-build
39+
resources:
40+
inputs:
41+
- name: repo
42+
resourceRef:
43+
name: cncamp-golang
44+
workspaces:
45+
- name: dockerconfig
46+
secret:
47+
secretName: docker-auth

tekton/github-resource.yaml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
apiVersion: tekton.dev/v1alpha1
2+
kind: PipelineResource
3+
metadata:
4+
name: cncamp-golang
5+
spec:
6+
type: git
7+
params:
8+
- name: url
9+
value: https://github.com/cncamp/golang.git
10+
- name: revision
11+
value: master
12+
secrets:
13+
- fieldName: authToken
14+
secretName: github-secrets
15+
secretKey: token
16+
---
17+
apiVersion: v1
18+
kind: Secret
19+
metadata:
20+
name: github-secrets
21+
type: Opaque
22+
data:
23+
token: changeme # in base64 encoded form
24+
---
25+
apiVersion: tekton.dev/v1alpha1
26+
kind: PipelineResource
27+
metadata:
28+
name: cncamp-test-image
29+
spec:
30+
type: image
31+
params:
32+
- name: url
33+
value: cncamp/test
34+
---
35+
apiVersion: tekton.dev/v1alpha1
36+
kind: PipelineResource
37+
metadata:
38+
name: test-cluster
39+
spec:
40+
type: cluster
41+
params:
42+
- name: url
43+
value: https://192.168.34.2:6443
44+
- name: username
45+
value: kubernetes-admin
46+
secrets:
47+
- fieldName: token
48+
secretKey: tokenKey
49+
secretName: target-cluster-secrets
50+
- fieldName: cadata
51+
secretKey: cadataKey
52+
secretName: target-cluster-secrets
53+
---
54+
apiVersion: v1
55+
kind: Secret
56+
metadata:
57+
name: docker-auth
58+
type: Opaque
59+
stringData:
60+
config.json: |-
61+
{
62+
"auths": {
63+
"https://index.docker.io/v1/": {
64+
"auth": "changeme"
65+
}
66+
}
67+
}
68+
---
69+
apiVersion: v1
70+
kind: ServiceAccount
71+
metadata:
72+
name: cncamp-sa
73+
secrets:
74+
- name: docker-auth

tekton/readme.MD

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
### setup tekton
2+
```
3+
kubectl apply --filename https://github.com/cncamp/mirror/blob/master/tekton-spec/release.yaml
4+
```
5+
### setup tekton cli tkn
6+
```
7+
curl -LO https://github.com/tektoncd/cli/releases/download/v0.20.0/tektoncd-cli-0.20.0_Linux-64bit.deb
8+
sudo dpkg -i ./tektoncd-cli-0.20.0_Linux-64bit.deb
9+
which tkn
10+
```

tekton/task-hello.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: tekton.dev/v1beta1
2+
kind: Task
3+
metadata:
4+
name: hello
5+
spec:
6+
steps:
7+
- name: hello
8+
image: ubuntu
9+
command:
10+
- echo
11+
args:
12+
- "Hello $(params.username)!"
13+
params:
14+
- name: username
15+
type: string

tekton/taskrun-hello.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: tekton.dev/v1beta1
2+
kind: TaskRun
3+
metadata:
4+
generateName: hello-run-
5+
spec:
6+
taskRef:
7+
name: hello
8+
params:
9+
- name: "username"
10+
value: "jesse"

0 commit comments

Comments
 (0)