Skip to content

Commit 50c6131

Browse files
committed
Add README for k8s multi cluster
Signed-off-by: Yoshiki Fujikane <[email protected]>
1 parent 6d9c411 commit 50c6131

File tree

8 files changed

+195
-0
lines changed

8 files changed

+195
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Kubernetes Multicluster Plugin
2+
3+
## Specification
4+
5+
現在の仕様は[RFC](../../../../../docs/rfcs/0014-multi-cluster-deployment-for-k8s.md)に記載しています。
6+
configのformatは不安定です。今後変更する可能性があります。
7+
8+
## Try k8s multicluster plugin on local
9+
10+
11+
- PipeCDのControl Planeを用意する
12+
13+
[pipe-cd/pipecd/cmd/pipecd/README.md](../../../../../cmd/pipecd/README.md) を参考に、ローカル環境にControl Planeを用意してください。
14+
15+
16+
- 2つのk8s clusterを用意する。
17+
18+
```
19+
kind create cluster --name cluster1
20+
kind export kubeconfig --name cluster1 --kubeconfig /path/to/kubeconfig/for/cluster1
21+
22+
kind create cluster --name cluster2
23+
kind export kubeconfig --name cluster2 --kubeconfig /path/to/kubeconfig/for/cluster2
24+
```
25+
26+
- pipedv1 をローカルで起動する
27+
28+
[pipe-cd/pipecd/cmd/pipedv1/README.md](../../../../../cmd/pipedv1/README.md) を参考に、ローカル環境にControl Planeを用意してください。
29+
この時、piped configの`spec.plugins` を以下を参考に修正して利用してください。
30+
31+
```yaml
32+
...
33+
plugins:
34+
- name: kubernetes_multicluster
35+
port: 7002
36+
url: file:///path/to/.piped/plugins/kubernetes_multicluster # It's OK using any value for now because it's a dummy. We will implement it later.
37+
deployTargets:
38+
- name: cluster1
39+
config:
40+
masterURL: https://127.0.0.1:61337 # shown by kubectl cluster-info
41+
kubeConfigPath: /path/to/kubeconfig/for/cluster1
42+
- name: cluster2
43+
config:
44+
masterURL: https://127.0.0.1:62082 # shown by kubectl cluster-info
45+
kubeConfigPath: /path/to/kubeconfig/for/cluster2
46+
```
47+
48+
**manifestを用意する**
49+
50+
- 新しくmanifest用のリポジトリを用意してください。
51+
プラグイン機構に対応する前の形式のapp.pipecd.yamlが存在すると、エラーが発生します。
52+
53+
- Examplesから動かしたいappをコピーしてcommitしてください。
54+
55+
**applicationを登録する**
56+
57+
![adding-application](./docs/static/adding-application.png)
58+
59+
60+
この時DeployTargetを複数選択してください。
61+
62+
63+
## Examples
64+
There are examples under `./example`.
65+
66+
| Name | Description |
67+
|------|-------------|
68+
| [simple](./example/simple/) | Deploy the same resources to the multiple clusters. |
69+
| [multi-sources-template-none](./example/multi-sources-template-none/) | Deploy the different resources to the multiple clusters. |
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: pipecd.dev/v1beta1
2+
kind: Application
3+
spec:
4+
name: multi-sources-template-none
5+
labels:
6+
env: example
7+
plugins:
8+
kubernetes_multicluster:
9+
quickSync:
10+
prune: true
11+
input:
12+
multiTargets:
13+
- target:
14+
name: cluster1
15+
manifests:
16+
- ./cluster1/deployment.yaml
17+
- target:
18+
name: cluster2
19+
manifests:
20+
- ./cluster2/deployment.yaml
21+
kubectlVersion: 1.32.2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: cluster1
5+
labels:
6+
app: cluster1
7+
spec:
8+
replicas: 2
9+
selector:
10+
matchLabels:
11+
app: cluster1
12+
pipecd.dev/variant: primary
13+
template:
14+
metadata:
15+
labels:
16+
app: cluster1
17+
pipecd.dev/variant: primary
18+
annotations:
19+
sidecar.istio.io/inject: "false"
20+
spec:
21+
containers:
22+
- name: helloworld
23+
image: ghcr.io/pipe-cd/helloworld:v0.32.0
24+
args:
25+
- server
26+
ports:
27+
- containerPort: 9085
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: cluster2
5+
labels:
6+
app: cluster2
7+
spec:
8+
replicas: 2
9+
selector:
10+
matchLabels:
11+
app: cluster2
12+
pipecd.dev/variant: primary
13+
template:
14+
metadata:
15+
labels:
16+
app: cluster2
17+
pipecd.dev/variant: primary
18+
annotations:
19+
sidecar.istio.io/inject: "false"
20+
spec:
21+
containers:
22+
- name: helloworld
23+
image: ghcr.io/pipe-cd/helloworld:v0.32.0
24+
args:
25+
- server
26+
ports:
27+
- containerPort: 9085
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: pipecd.dev/v1beta1
2+
kind: Application
3+
spec:
4+
name: simple
5+
labels:
6+
env: example
7+
plugins:
8+
kubernetes_multicluster:
9+
input:
10+
manifests:
11+
- deployment.yaml
12+
- service.yaml
13+
kubectlVersion: 1.32.2
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: simple
5+
labels:
6+
app: simple
7+
spec:
8+
replicas: 2
9+
selector:
10+
matchLabels:
11+
app: simple
12+
pipecd.dev/variant: primary
13+
template:
14+
metadata:
15+
labels:
16+
app: simple
17+
pipecd.dev/variant: primary
18+
annotations:
19+
sidecar.istio.io/inject: "false"
20+
spec:
21+
containers:
22+
- name: helloworld
23+
image: ghcr.io/pipe-cd/helloworld:v0.32.0
24+
args:
25+
- server
26+
ports:
27+
- containerPort: 9085
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: simple
5+
spec:
6+
selector:
7+
app: simple
8+
ports:
9+
- protocol: TCP
10+
port: 9085
11+
targetPort: 9085

0 commit comments

Comments
 (0)