Skip to content

Commit fe0614e

Browse files
committed
feat: add docs and samples for GCP
This PR will add an initial doc for using the bootstrap provider with GCP. Signed-off-by: Spencer Smith <[email protected]>
1 parent 63d035c commit fe0614e

File tree

5 files changed

+282
-0
lines changed

5 files changed

+282
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# cluster-api-bootstrap-provider-talos
2+
3+
A [cluster-api](https://github.com/kubernetes-sigs/cluster-api) bootstrap provider for deploying [Talos](https://github.com/talos-systems/talos) clusters.
4+
5+
6+
#### Getting Started Guides:
7+
8+
- [GCP](docs/GCP.md)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: cluster.x-k8s.io/v1alpha2
2+
kind: Cluster
3+
metadata:
4+
name: test1
5+
namespace: default
6+
spec:
7+
clusterNetwork:
8+
pods:
9+
cidrBlocks:
10+
- 192.168.0.0/16
11+
apiServerPort: 443
12+
infrastructureRef:
13+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
14+
kind: GCPCluster
15+
name: test1
16+
namespace: default
17+
---
18+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
19+
kind: GCPCluster
20+
metadata:
21+
name: test1
22+
namespace: default
23+
spec:
24+
project: my-gcp-project
25+
region: us-central1
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
2+
kind: TalosConfig
3+
metadata:
4+
name: test1-controlplane-0
5+
labels:
6+
cluster.x-k8s.io/cluster-name: test1
7+
spec:
8+
machineType: init
9+
---
10+
apiVersion: cluster.x-k8s.io/v1alpha2
11+
kind: Machine
12+
metadata:
13+
labels:
14+
cluster.x-k8s.io/cluster-name: test1
15+
cluster.x-k8s.io/control-plane: "true"
16+
name: test1-controlplane-0
17+
namespace: default
18+
spec:
19+
bootstrap:
20+
configRef:
21+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
22+
kind: TalosConfig
23+
name: test1-controlplane-0
24+
namespace: default
25+
infrastructureRef:
26+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
27+
kind: GCPMachine
28+
name: test1-controlplane-0
29+
namespace: default
30+
version: 1.16.1
31+
---
32+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
33+
kind: GCPMachine
34+
metadata:
35+
name: test1-controlplane-0
36+
namespace: default
37+
spec:
38+
instanceType: n1-standard-2
39+
zone: us-central1-a
40+
image: projects/my-gcp-project/global/images/talos-capi-test
41+
serviceAccounts: {}
42+
publicIP: true
43+
44+
---
45+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
46+
kind: TalosConfig
47+
metadata:
48+
name: test1-controlplane-1
49+
labels:
50+
cluster.x-k8s.io/cluster-name: test1
51+
spec:
52+
machineType: controlplane
53+
---
54+
apiVersion: cluster.x-k8s.io/v1alpha2
55+
kind: Machine
56+
metadata:
57+
labels:
58+
cluster.x-k8s.io/cluster-name: test1
59+
cluster.x-k8s.io/control-plane: "true"
60+
name: test1-controlplane-1
61+
namespace: default
62+
spec:
63+
bootstrap:
64+
configRef:
65+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
66+
kind: TalosConfig
67+
name: test1-controlplane-1
68+
namespace: default
69+
infrastructureRef:
70+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
71+
kind: GCPMachine
72+
name: test1-controlplane-1
73+
namespace: default
74+
version: 1.16.1
75+
---
76+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
77+
kind: GCPMachine
78+
metadata:
79+
name: test1-controlplane-1
80+
namespace: default
81+
spec:
82+
instanceType: n1-standard-2
83+
zone: us-central1-a
84+
image: projects/my-gcp-project/global/images/talos-capi-test
85+
serviceAccounts: {}
86+
publicIP: true
87+
88+
---
89+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
90+
kind: TalosConfig
91+
metadata:
92+
name: test1-controlplane-2
93+
labels:
94+
cluster.x-k8s.io/cluster-name: test1
95+
spec:
96+
machineType: controlplane
97+
---
98+
apiVersion: cluster.x-k8s.io/v1alpha2
99+
kind: Machine
100+
metadata:
101+
labels:
102+
cluster.x-k8s.io/cluster-name: test1
103+
cluster.x-k8s.io/control-plane: "true"
104+
name: test1-controlplane-2
105+
namespace: default
106+
spec:
107+
bootstrap:
108+
configRef:
109+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
110+
kind: TalosConfig
111+
name: test1-controlplane-2
112+
namespace: default
113+
infrastructureRef:
114+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
115+
kind: GCPMachine
116+
name: test1-controlplane-2
117+
namespace: default
118+
version: 1.16.1
119+
---
120+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
121+
kind: GCPMachine
122+
metadata:
123+
name: test1-controlplane-2
124+
namespace: default
125+
spec:
126+
instanceType: n1-standard-2
127+
zone: us-central1-a
128+
image: projects/my-gcp-project/global/images/talos-capi-test
129+
serviceAccounts: {}
130+
publicIP: true
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
2+
kind: TalosConfigTemplate
3+
metadata:
4+
name: test1-md-0
5+
namespace: default
6+
spec:
7+
template:
8+
spec:
9+
machineType: "join"
10+
---
11+
apiVersion: cluster.x-k8s.io/v1alpha2
12+
kind: MachineDeployment
13+
metadata:
14+
labels:
15+
cluster.x-k8s.io/cluster-name: test1
16+
nodepool: nodepool-0
17+
name: test1-md-0
18+
namespace: default
19+
spec:
20+
replicas: 2
21+
selector:
22+
matchLabels:
23+
cluster.x-k8s.io/cluster-name: test1
24+
nodepool: nodepool-0
25+
template:
26+
metadata:
27+
labels:
28+
cluster.x-k8s.io/cluster-name: test1
29+
nodepool: nodepool-0
30+
spec:
31+
bootstrap:
32+
configRef:
33+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha2
34+
kind: TalosConfigTemplate
35+
name: test1-md-0
36+
namespace: default
37+
infrastructureRef:
38+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
39+
kind: GCPMachineTemplate
40+
name: test1-md-0
41+
namespace: default
42+
version: 1.16.1
43+
---
44+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
45+
kind: GCPMachineTemplate
46+
metadata:
47+
name: test1-md-0
48+
namespace: default
49+
spec:
50+
template:
51+
spec:
52+
instanceType: n1-standard-2
53+
zone: us-central1-a
54+
image: projects/my-gcp-project/global/images/talos-capi-test

docs/GCP.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# cluster-api-bootstrap-provider-talos on GCP
2+
3+
This guide will detail how to deploy the Talos provider into an existing Kubernetes cluster, as well as how to configure it to create Clusters and Machines in GCP.
4+
5+
#### Import Image
6+
7+
To import the image, you must download a .tar.gz talos release, add it to Google storage, and import it as an image.
8+
9+
- Download the `gcp.tar.gz` image from our [Github releases](https://github.com/talos-systems/talos/releases).
10+
11+
- Follow the [Google instructions](https://cloud.google.com/compute/docs/images/import-existing-image#import_image) on importing an image using cloud storage.
12+
13+
#### Prepare bootstrap cluster
14+
15+
In your cluster that you'll be using to create other clusters, you must prepare a few bits.
16+
17+
##### Install GCP Provider
18+
19+
- Git clone the [GCP infrastructure provider](https://github.com/kubernetes-sigs/cluster-api-provider-gcp). Because the GCP provider is being actively developed, it's currently best to build the manifests we need instead of relying on releases.
20+
21+
- In GCP, create a service account and generate keys for the account. This will result in a JSON file containing the keys. General instructions for generating the key can be found [here](https://cloud.google.com/iam/docs/creating-managing-service-account-keys).
22+
23+
- In the repo you checked out above, set your environment variables and generate the manifests:
24+
25+
```bash
26+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
27+
export GCP_REGION=us-central1
28+
export GCP_PROJECT=my-gcp-project
29+
30+
make generate-examples
31+
```
32+
33+
- Deploy the generated infrastructure components with:
34+
35+
```bash
36+
kubectl create -f examples/_out/provider-components.yaml
37+
```
38+
39+
- Because this ships with the kubeadm bootstrapper, we'll delete that deployment. It's not needed.
40+
41+
```bash
42+
kubectl delete deploy -n cabpk-system cabpk-controller-manager
43+
```
44+
45+
##### Install Talos Bootstrap Provider
46+
47+
- Git clone this repo
48+
49+
- In the directory, apply the manifests using kustomize:
50+
51+
```bash
52+
kustomize build config/default/ | kubectl apply -f -
53+
```
54+
55+
#### Create new clusters
56+
57+
There are sample manifests in [config/samples/cluster-deployment/gcp](../config/samples/cluster-deployment/gcp) for deploying clusters. These will be our starting point.
58+
59+
- Edit `gcp-cluster.yaml`, `gcp-controlplane.yaml`, and `gcp-workers.yaml` with your relevant data. You will specifically want to edit the GCP image, as well as your GCP project.
60+
61+
- From `config/samples/cluster-deployment/gcp` issue `kubectl apply -f .`.
62+
63+
- The talos config for your controlplane-0 node can be found with `kubectl get talosconfig -o yaml test1-controlplane-0 -o jsonpath='{.status.talosConfig}'`.
64+
65+
- You must target the public IP of the controlplane-0 node (found in GCP console) with `osctl config target $EXTERNAL_IP` before osctl will work.

0 commit comments

Comments
 (0)