Generic - Create and Import Cluster
Create generic cluster with Kosmos
Prerequisite
Login to Kosmos Operator (dev) endpoints by Kosmos CLI:
kosmos login console.kosmos.spcplatform.com --access-key [AccessKey]IAM account with root or admin access policies for setting up the permissions.
Target cluster should have a cluster node group for setup.
1. Generate new config
1-A. Update kubeconfig
- Update kubeconfig with the target cluster.
- Use target cluster’s name as
${CLUSTER_NAME}. - Use target cluster’s region as
${REGION}. - Use the output as
${CONTEXT_NAME}.
For an EKS cluster:
Update kubeconfig file with the EKS cluster
aws eks update-kubeconfig --name ${CLUSTER_NAME} --region ${REGION} --profile ${profile}
Output example:
Added new context arn:aws:eks:${REGION}:[ACCOUNT_ID]:cluster/${CLUSTER_NAME} to [kubeconfig path]/.kube/config
For a GKE cluster:
gcloud container clusters get-credentials ${CLUSTER_NAME} --zone ${REGION} --project <GCLOUD_PROJECT_NAME>
Output example:
- Fetching cluster endpoint and auth data.
- kubeconfig entry generated for ${CLUSTER_NAME}
1-B. Use target cluster context
Switch to the target cluster context using ${CONTEXT_NAME}.
kubectl config use-context ${CONTEXT}
Output example:
- Switched to context “${CONTEXT}”
1-C. Generate config
Generate a configuration file with the following command:
kosmos generate admin-kube-config
Example output:
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: [AUTH_DATA] # LS0t...
server: [SERVER]
name: default
contexts:
- context:
cluster: default
user: default
name: default
current-context: default
kind: Config
preferences: {}
users:
- name: default
user:
token: [TOKEN] # eyJh...
2. Create generic cluster
2-A. Use Kosmos cluster context
Switch to the Kosmos cluster context.
kubectl config use-context loft_loft-cluster
2-B. Create sample file
Create a configuration file with the following details:
- Use target cluster’s name as
${CLUSTER_NAME}. - Use 1-C
[AUTH_DATA]as${AUTH_DATA}. - Use 1-C
[SERVER]as${SERVER}. - Use 1-C
[TOKEN]as${TOKEN}. - Use Kosmos username as
${USER_NAME}. - Use fleet name as
${FLEET_NAME}.
Reference: Using EKS Cluster | 3. Create Fleet
Sample file: generic_sample.yaml
apiVersion: storage.kosmos.spcplatform.com/v1
kind: GenericCluster
metadata:
name: ${CLUSTER_NAME}
namespace: ${FLEET_NAME}
spec:
name: ${CLUSTER_NAME}
description: An example GenericCluster deployed in Kosmos environment
oidcConfig:
issuerUri: ""
authorization:
adminUsers:
- ${USER_NAME}
loggingConfig:
componentConfig:
enableComponents:
- SYSTEM_COMPONENTS
- WORKLOADS
monitoringConfig:
managedPrometheusConfig:
enabled: true
kubeConfig: |
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: ${AUTH_DATA} # LS0t...
server: ${SERVER}
name: default
contexts:
- context:
cluster: default
user: default
name: default
current-context: default
kind: Config
preferences: {}
users:
- name: default
user:
token: ${TOKEN} # eyJh...
2-C. Create generic cluster
Apply the sample configuration file to create the generic cluster.
kubectl apply -f generic_sample.yaml
Import Generic Cluster
To import generic cluster, please refer to Import generic cluster using Terraform