Your hybrid cloud presence is growing exponentially. Isn’t everyone’s? As some operations go all-in on hyperscaler public clouds, others have found a renewed focus toward on-premises, highly specialized clusters built by in-house automation that have long been a staple in the Kubernetes ecosystem. Whether you are all-in on public clouds or have a suite of custom automation to generate the perfect cluster on-premises, Red Hat Advanced Cluster Management for Kubernetes auto-import functionality and automation tools can simplify your management experience.
The function was released in Red Hat Advanced Cluster Management for Kubernetes version 2.3 and supports custom automation with Red Hat Ansible, HashiCorp Terraform, BASH, and beyond. It can leverage auto-import in the YAML file or through cm-cli to quickly and easily import a new cluster into a Red Hat Advanced Cluster Management for Kubernetes hub cluster. Importing the clusters allows you to quickly automate application rollout, leverage policies for easier day-2 configurations, and collect cluster health metrics in a matter of minutes.
Importing a cluster with only oc
Imagine that we have an Ansible Playbook that creates a Red Hat OpenShift Container Platform cluster on-premises. This cluster will be perfect for our workload, and - oh - it just completed. Perfect timing!
Creating a secret
So we now have our new Red Hat OpenShift Container Platform cluster online. Let’s call it my-new-cluster. We also have the cluster kubeconfig. Our next step, while logged into our hub cluster, is to tell the hub cluster how to reach our new cluster. This task is as simple as creating a secret in the namespace that we choose. This Secret is only used during the import process and is automatically removed afterward. We’ll create a secret that is similar to the following example:
apiVersion: v1
kind: Secret
metadata:
name: auto-import-secret
namespace: my-new-cluster
stringData:
autoImportRetry: 10
kubeconfig: |-
<the-full-contents-of-my-new-cluster-kubeconfig>
...
type: Opaque
There are some optional configuration changes that we can make. For example, we can change the target namespace and the number of retries that are attempted. In the next example, we’ll use a namespace made for this cluster named my-new-cluster with 10 retries.
Also, in case you don’t want to provide your kubeconfig information, you have the option of providing a server and token in the secret instead. See the following example:
apiVersion: v1
kind: Secret
metadata:
name: auto-import-secret
namespace: my-new-cluster
stringData:
autoImportRetry: 10
token: sha256~xxxxx <put-your-token-here)
server: https://api.xxxx:6443 <my-new-cluster-api-url>
...
type: Opaque
Making our ManagedCluster
Protected with our secret, our hub cluster can now import our cluster. We just have to tell it what to call the new managed cluster, which namespace we would like to use for the ManagedCluster resource and related resources, and what management functions we want active on the cluster. Once again, we’ll run oc apply for the YAML, then the import will automatically begin. See the following example of possible YAML content that will complete the import:
apiVersion: cluster.open-cluster-management.io/v1
kind: ManagedCluster
metadata:
labels:
cloud: auto-detect
vendor: auto-detect
name: my-new-cluster
spec:
hubAcceptsClient: true
leaseDurationSeconds: 60
---
apiVersion: agent.open-cluster-management.io/v1
kind: KlusterletAddonConfig
metadata:
name: my-new-cluster
namespace: my-new-cluster
spec:
clusterName: my-new-cluster
clusterNamespace: my-new-cluster
clusterLabels:
cloud: auto-detect
vendor: auto-detect
applicationManager:
enabled: true|false
argocdCluster: true|false
policyController:
enabled: true|false
searchCollector:
enabled: true|false
certPolicyController:
enabled: true|false
iamPolicyController:
enabled: true|false
As you can see, we have lots of fun toggles to modify. For this case, we're just going to enable all of the add-ons. We also need to fill in our cluster name and cluster namespace, as we did previously. After we apply this YAML, the import should begin. In a few minutes, my-new-cluster will be fully managed.
Importing a cluster with cm-cli
The Red Hat Advanced Cluster Management for Kubernetes team’s automation-friendly community CLI, cm-cli, includes a simplified auto-import experience, alongside other handy cluster and kube-context management features.
Let’s assume we’ve created a second cluster using our Ansible playbook and call it my-new-cluster-2. This time, let’s import it with cm.
-
Make sure you're logged in to your hub cluster.
-
After you've logged in, we can import with a
kubeconfig. See the following command:cm attach cluster my-new-cluster-2 --cluster-kubeconfig=<cluster-kubeconfig-file>In this case, we set our cluster name inline in the command to
my-new-cluster-2, or use the API URL and token:cm attach cluster my-new-cluster-2 --cluster-server=<api-url> --cluster-token=<token>If you are curious, you can run
cm attach cluster -hand customize the examplevalues.yamlfile to enable or disable specific add-ons. When you’re ready to import with a customizedvalues.yamlfile, runattach clusteras before, but include--values=<values-file-name>.
Detaching a managed cluster
You can also detach a managed cluster. Red Hat Advanced Cluster Management supports cleanly detaching and reattaching clusters easily through the oc and [cm-cli](https://github.com/open-cluster-management/cm-cli) tools.
- You can detach with
ocby running the following command:
oc delete managedcluster <managed-cluster-name>
- You can detach it by using the
cmCLI by running:
cm detach cluster <managed-cluster-name>
저자 소개
유사한 검색 결과
Data-driven automation with Red Hat Ansible Automation Platform
Ford's keyless strategy for managing 200+ Red Hat OpenShift clusters
Technically Speaking | Taming AI agents with observability
You Can’t Automate The Difficult Decisions | Code Comments
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
가상화
온프레미스와 클라우드 환경에서 워크로드를 유연하게 운영하기 위한 엔터프라이즈 가상화의 미래