Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit585b8b4

Browse files
Add managed clusters with Terraform and Helm
1 parent0bc28f7 commit585b8b4

File tree

1 file changed

+78
-175
lines changed

1 file changed

+78
-175
lines changed
Lines changed: 78 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
---
22
title:"Add external clusters to GitOps Runtimes"
3-
description:"Manage multiple remote clusters withsingle GitOps Runtime"
3+
description:"Manage multiple remote clusters witha GitOps Runtime"
44
group:installation
55
sub_group:gitops
66
toc:true
77
---
88

9-
Register external clusters to provisioned Hybrid or Hosted GitOps Runtimes in Codefresh. Once you add an external cluster, you can deploy applications to that cluster without having to install Argo CD on the clusters in order to do so. Manage multiple external clusters through a single Runtime.
9+
Once you have an Argo CD installation as part of a[hybrid]({{site.baseurl}}/docs/installation/gitops/hybrid-gitops/) or[hosted runtime]({{site.baseurl}}/docs/installation/gitops/hosted-runtime/) you
10+
can add external deployment clusters to them.
1011

11-
When you add an external cluster to a provisioned GitOps Runtime, the cluster is registered as a managed cluster. A managed cluster is treated as any other managed K8s resource, meaning thatyou canmonitor its health and sync status,deploy applications toit, view information in the Applications dashboard, and remove thecluster from the Runtime's managed list.
12+
Once you add an external cluster,you can deploy applications tothat cluster without having to install Argo CD on theclusters in order to do so.
1213

13-
Add managed clusters through:
14-
* GitOps CLI
15-
* Kustomize
14+
When you add an external cluster to a provisioned GitOps Runtime, the cluster is registered as a managed cluster. A managed cluster is treated as any other managed K8s resource, meaning that you can monitor its health and sync status, deploy applications to it, view information in the Applications dashboard, and remove the cluster from the Runtime's managed list.
1615

1716
Adding a managed cluster via Codefresh ensures that Codefresh applies the required RBAC resources (`ServiceAccount`,`ClusterRole` and`ClusterRoleBinding`) to the target cluster, creates a`Job` that updates the selected Runtime with the information, registers the cluster in Argo CD as a managed cluster, and updates the platform with the new cluster information.
1817

1918

20-
##Add a managed cluster with GitOps CLI
21-
Add an external cluster to a provisioned GitOps Runtime through the GitOps CLI. When adding the cluster, you can also add labels and annotations to the cluster, which are added to the cluster secret created by Argo CD.
22-
Optionally, to first generate the YAML manifests, and then manually apply them, use the`dry-run` flag in the CLI.
2319

24-
**Before you begin**
20+
21+
##Prerequisites
2522

2623
* For_Hosted GitOps_ Runtimes:[Configure access to these IP addresses]({{site.baseurl}}/docs/administration/platform-ip-addresses/)
27-
* Verify that:
28-
* Your Git personal access token is valid and has the[required scopes]({{site.baseurl}}/docs/reference/git-tokens)
29-
* You have the[latest version of the Codefresh CLI]({{site.baseurl}}/docs/installation/gitops/upgrade-gitops-cli/)
24+
* Your Git personal access token is valid and has the[required scopes]({{site.baseurl}}/docs/reference/git-tokens)
25+
* You have the[latest version of the Codefresh CLI]({{site.baseurl}}/docs/installation/gitops/upgrade-gitops-cli/)
26+
* You have created a Codefresh token in user settings
27+
* You know the ingress host of your runtime using`cf runtime list`
28+
29+
###Add a managed cluster with GitOps CLI
30+
Add an external cluster to a provisioned GitOps Runtime through the GitOps CLI. When adding the cluster, you can also add labels and annotations to the cluster, which are added to the cluster secret created by Argo CD.
31+
Optionally, to first generate the YAML manifests, and then manually apply them, use the`dry-run` flag in the CLI.
3032

3133
**How to**
3234

@@ -59,174 +61,53 @@ Optionally, to first generate the YAML manifests, and then manually apply them,
5961
Here is an example of the YAML manifest generated with the`--dry-run` flag. Note that the example has placeholders, which are replaced with the actual values during the`--dry-run`.
6062

6163

62-
```yaml
63-
apiVersion:v1
64-
kind:ServiceAccount
65-
metadata:
66-
name:argocd-manager
67-
namespace:kube-system
68-
---
69-
apiVersion:rbac.authorization.k8s.io/v1
70-
kind:ClusterRole
71-
metadata:
72-
name:argocd-manager-role
73-
rules:
74-
-apiGroups:
75-
-'*'
76-
resources:
77-
-'*'
78-
verbs:
79-
-'*'
80-
-nonResourceURLs:
81-
-'*'
82-
verbs:
83-
-'*'
84-
---
85-
apiVersion:rbac.authorization.k8s.io/v1
86-
kind:ClusterRoleBinding
87-
metadata:
88-
name:argocd-manager-role-binding
89-
roleRef:
90-
apiGroup:rbac.authorization.k8s.io
91-
kind:ClusterRole
92-
name:argocd-manager-role
93-
subjects:
94-
-kind:ServiceAccount
95-
name:argocd-manager
96-
namespace:kube-system
97-
---
98-
apiVersion:v1
99-
data:
100-
contextName:<context-name>
101-
ingressUrl:<ingressUrl>
102-
server:<server>
103-
kind:ConfigMap
104-
metadata:
105-
name:csdp-add-cluster-cm
106-
namespace:kube-system
107-
---
108-
apiVersion:v1
109-
data:
110-
annotations:|
111-
<annotation-key1>:<annotation-value1>
112-
<annotation-key2>:<annotation-value2>
113-
contextName:<context-name>
114-
ingressUrl:ingressurl.com
115-
labels:|
116-
<label-key1>:<label-value1>
117-
<label-key2>:<label-value2>
118-
server:https://<hash>.gr7.us-east-1.eks.amazonaws.com/
119-
csdpToken:<csdpToken>
120-
kind:Secret
121-
metadata:
122-
name:csdp-add-cluster-secret
123-
namespace:kube-system
124-
type:Opaque
125-
---
126-
apiVersion:batch/v1
127-
kind:Job
128-
metadata:
129-
name:csdp-add-cluster-job
130-
namespace:kube-system
131-
spec:
132-
template:
133-
metadata:
134-
name:csdp-add-cluster-pod
135-
spec:
136-
containers:
137-
-args:
138-
-./add-cluster.sh
139-
command:
140-
-bash
141-
env:
142-
-name:SERVICE_ACCOUNT_NAME
143-
valueFrom:
144-
fieldRef:
145-
fieldPath:spec.serviceAccountName
146-
-name:INGRESS_URL
147-
valueFrom:
148-
configMapKeyRef:
149-
key:ingressUrl
150-
name:csdp-add-cluster-cm
151-
-name:CSDP_TOKEN
152-
valueFrom:
153-
secretKeyRef:
154-
key:csdpToken
155-
name:csdp-add-cluster-secret
156-
-name:CONTEXT_NAME
157-
valueFrom:
158-
configMapKeyRef:
159-
key:contextName
160-
name:csdp-add-cluster-cm
161-
-name:SERVER
162-
valueFrom:
163-
configMapKeyRef:
164-
key:server
165-
name:csdp-add-cluster-cm
166-
image:quay.io/codefresh/csdp-add-cluster:0.1.0
167-
imagePullPolicy:Always
168-
name:main
169-
resources:
170-
limits:
171-
cpu:"1"
172-
memory:512Mi
173-
requests:
174-
cpu:"0.2"
175-
memory:256Mi
176-
restartPolicy:Never
177-
serviceAccount:argocd-manager
178-
ttlSecondsAfterFinished:600
64+
The new cluster is registered to the GitOps Runtime as a managed cluster.
17965

180-
```
66+
###Add a managed cluster with Kustomize
18167

182-
The new cluster is registered to the GitOps Runtime as a managed cluster.
68+
1. Clone locally[https://github.com/codefresh-io/csdp-official/tree/main/add-cluster/kustomize](https://github.com/codefresh-io/csdp-official/tree/main/add-cluster/kustomize).
69+
1. Update confimap.yml and secret.yml with the require values
70+
1. Run`kustomize build` or`kubectl -k` to apply the final result to the cluster
71+
72+
You can get the`ingressUrl` value of your runtime by running`cf runtime list` in your terminal
73+
after authenticating to the[Codefresh GitOps CLI]({{site.baseurl}}/docs/installation/cli/).
74+
75+
###Add a managed cluster with Helm
76+
77+
A Helm chart is published athttps://chartmuseum.codefresh.io/csdp-add-cluster. You can see the source templates at[https://github.com/codefresh-io/csdp-official/tree/main/add-cluster/helm](https://github.com/codefresh-io/csdp-official/tree/main/add-cluster/helm).
78+
79+
To deploy the chart copy locally[https://github.com/codefresh-io/csdp-official/blob/main/add-cluster/helm/values.yaml](https://github.com/codefresh-io/csdp-official/blob/main/add-cluster/helm/values.yaml) and fill in the required values.
80+
81+
Then run
82+
83+
```shell
84+
helm repo add csdp-add-cluster https://chartmuseum.codefresh.io/csdp-add-cluster
85+
helm search repo csdp-add-cluster
86+
helm install csdp-add-cluster/csdp-add-cluster -f values.yaml --generate-name
87+
```
18388

184-
##Add a managed cluster with Kustomize
185-
186-
Create a`kustomization.yaml` file with the information shown in the example below, and run`kustomize build` on it.
187-
188-
```yaml
189-
apiVersion:kustomize.config.k8s.io/v1beta1
190-
kind:Kustomization
191-
namespace:kube-system
192-
193-
configMapGenerator:
194-
-name:csdp-add-cluster-cm
195-
namespace:kube-system
196-
behavior:merge
197-
literals:
198-
# contextName is the name of the kube context (in the local kubeconfig file) that connects to the target cluster
199-
-"contextName=<contextName>"
200-
# ingressUrl is the url used to access the Codefresh runtime
201-
# example https://some.domain.name
202-
-"ingressUrl=<ingressUrl>"
203-
# server is the k8s cluster API endpoint url
204-
# can be obtained by
205-
# CONTEXT_NAME=<TARGET_CONTEXT_NAME>
206-
# CLUSTER_NAME=$(kubectl config view --raw --flatten -o jsonpath='{.contexts[?(@.name == "'"${CONTEXT_NAME}"'")].context.cluster}')
207-
# kubectl config view --raw --flatten -o jsonpath='{.clusters[?(@.name == "'"${CLUSTER_NAME}"'")].cluster.server}'
208-
-"server=https://<hash>.gr7.us-east-1.eks.amazonaws.com/"
209-
-|
210-
annotations=<key1: value1>
211-
<key2.with.dots/and-backslash: value2 with: as:pace>
212-
-|
213-
labels=<and.another-one/field: value>
214-
<label.key.with.long.name/field: some_long_value>
215-
216-
secretGenerator:
217-
-behavior:merge
218-
literals:
219-
-csdpToken=<your-personal-token>
220-
name:csdp-add-cluster-secret
221-
namespace:kube-system
222-
223-
resources:
224-
-https://github.com/codefresh-io/csdp-official/add-cluster/kustomize?ref=<runtimeVersion>
225-
```
22689

22790
You can get the`ingressUrl` value of your runtime by running`cf runtime list` in your terminal
22891
after authenticating to the[Codefresh GitOps CLI]({{site.baseurl}}/docs/installation/cli/).
22992

93+
###Add a manage cluster with Terraform
94+
95+
Use the[Helm provider](https://registry.terraform.io/providers/hashicorp/helm/latest/docs) as any other Helm chart.
96+
97+
```hcl
98+
resource "helm_release" "my-managed-cluster" {
99+
name = "my-managed-cluster"
100+
101+
repository = "https://chartmuseum.codefresh.io/csdp-add-cluster"
102+
chart = "csdp-add-cluster"
103+
values = [
104+
"${file("values.yaml")}"
105+
]
106+
}
107+
```
108+
109+
And then apply the file using Terraform or your favorite workflow tool.
110+
230111
##Work with managed clusters
231112
Work with managed clusters in either the Topology or List Runtime views. For information on Runtime views, see[Runtime views]({{site.baseurl}}/docs/installation/gitops/monitor-manage-runtimes/#gitops-runtime-views).
232113
As the cluster is managed through the Runtime, updates to the Runtime automatically updates the components on all the managed clusters that include it.
@@ -254,6 +135,12 @@ Install Argo Rollouts with a single click to execute rollout instructions, deplo
254135
max-width="40%"
255136
%}
256137

138+
##Remove a managed cluster
139+
140+
When you want to remove a cluster as a deployment target you can unlink it from the runtime that manages it.
141+
142+
Note that this only removes the management link between your runtime and your cluster. It doesn't do anything with the applications that are already running on the cluster.
143+
257144

258145
###Remove a managed cluster from the Codefresh UI
259146
Remove a cluster from the Runtime's list of managed clusters from the Codefresh UI.
@@ -288,6 +175,22 @@ Remove a cluster from the list managed by the GitOps Runtime, through the GitOp
288175
`<server-url>` is the URL of the server on which the managed cluster is installed.
289176

290177

178+
179+
180+
###Remove with Kustomize
181+
182+
Run`kubectl delete -f <your_yaml>` with the result of the`kustomize build` command
183+
that you run during installation
184+
185+
###Remove with Helm
186+
187+
Run`helm delete <release_name>` with the name of the release that was created
188+
during installation.
189+
190+
###Remove with terraform
191+
192+
Use the`terraform destroy` command.
193+
291194
##Related articles
292195
[Add Git Sources to GitOps Runtimes]({{site.baseurl}}/docs/installation/gitops/git-sources/)
293-
[Monitoring & managing GitOps Runtimes]({{site.baseurl}}/docs/installation/gitops/monitor-manage-runtimes/)
196+
[Monitoring & managing GitOps Runtimes]({{site.baseurl}}/docs/installation/gitops/monitor-manage-runtimes/)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp