Advanced cluster management
Advanced cluster management with OSM client
This guide contains OSM client commands to operate infrastructure and applications following the new declarative framework introduced in Release SIXTEEN.
OSM client initialization
export OSM_HOSTNAME=$(kubectl get -n osm -o jsonpath="{.spec.rules[0].host}" ingress nbi-ingress)
echo "OSM_HOSTNAME: $OSM_HOSTNAME"
VIM/Cloud account operations
VIM/Cloud account registration
Azure Cloud account registration
export OSM_CREDS_FOLDER="${HOME}/vims"
source ${OSM_CREDS_FOLDER}/azure-env.rc
osm vim-create --name azure-site --account_type azure \
--auth_url http://www.azure.com \
--user "$AZURE_CLIENT_ID" --password "$AZURE_SECRET" --tenant "$AZURE_TENANT" \
--description "AZURE site" \
--creds ${OSM_CREDS_FOLDER}/azure-credentials.json \
--config "{region_name: westeurope, resource_group: '<AZURE_RG>', subscription_id: '$AZURE_SUBSCRIPTION_ID', vnet_name: 'osm', flavors_pattern: '^Standard'}"
File ${OSM_CREDS_FOLDER}/azure-env.rc:
export AZURE_CLIENT_ID="**********************************"
export AZURE_TENANT="**********************************"
export AZURE_SECRET="**********************************"
export AZURE_SUBSCRIPTION_ID="**********************************"
File ${OSM_CREDS_FOLDER}/azure-credentials.json:
{
"clientId": "{************************************}",
"clientSecret": "************************************",
"subscriptionId": "************************************",
"tenantId": "************************************",
"activeDirectoryEndpointUrl": "https://login.microsoftonline.com",
"resourceManagerEndpointUrl": "https://management.azure.com/",
"activeDirectoryGraphResourceId": "https://graph.windows.net/",
"sqlManagementEndpointUrl": "https://management.core.windows.net:8443/",
"galleryEndpointUrl": "https://gallery.azure.com/",
"managementEndpointUrl": "https://management.core.windows.net/"
}
The JSON credentials file corresponds to the service principal credentials obtained during the service principal creation: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-clusters-in-rancher-setup/set-up-clusters-from-hosted-kubernetes-providers/aks
az ad sp create-for-rbac --role Contributor --scopes /subscriptions/<subscription-id>/resourceGroups/<resource-group-name>
Dummy Cloud account registration
If you have existing clusters, you can register them to a dummy cloud account. In order to register a dummy cloud account, you can proceed this way:
osm vim-create --name mylocation1 \
--user u --password p --tenant p \
--account_type dummy \
--auth_url http://localhost/dummy
VIM/Cloud account deletion
osm vim-delete azure-site
Cluster operations
Cluster creation
CLUSTER_NAME=cluster1
CLUSTER_VM_SIZE=Standard_D2_v2
CLUSTER_NODES=1
REGION_NAME=northeurope
VIM_ACCOUNT=azure-site
RESOURCE_GROUP=<AZURE_RG>
KUBERNETES_VERSION="1.30"
osm cluster-create --node-count ${CLUSTER_NODES} --node-size ${CLUSTER_VM_SIZE} --version ${KUBERNETES_VERSION} --vim-account ${VIM_ACCOUNT} --description "Cluster1" ${CLUSTER_NAME} --region-name ${REGION_NAME} --resource-group ${RESOURCE_GROUP}
osm cluster-list
osm cluster-show cluster1
When the cluster is created, the field resourceState should be READY.
Getting kubeconfig
Once the cluster is ready, you can get the credentials in this way:
osm cluster-show cluster1 -o jsonpath='{.credentials}' | yq -P
# Save them in a file
osm cluster-show cluster1 -o jsonpath='{.credentials}' | yq -P > ~/kubeconfig-cluster1.yaml
# Test it
export KUBECONFIG=~/kubeconfig-cluster1.yaml
kubectl get nodes
In case credentials are renewed by the cloud policy, credentials can be obtained using this command:
osm cluster-get-credentials cluster1
Cluster scale
osm cluster-scale cluster1 --node-count 2
Cluster deletion
osm cluster-delete cluster1
Cluster registration
This should be run over a cluster that was not created by OSM:
CLUSTER_NAME=cluster2
VIM_ACCOUNT=azure-site
osm cluster-register --creds ~/kubeconfig-${CLUSTER_NAME}.yaml --vim ${VIM_ACCOUNT} --description "My existing K8s cluster" ${CLUSTER_NAME}
osm cluster-list
osm cluster-show cluster2
When the cluster is created, the field resourceState should be READY.
Cluster deregistration
osm cluster-deregister cluster2
OKA operations
OKA addition
# git clone --recursive https://osm.etsi.org/gitlab/vnf-onboarding/osm-packages.git
export OSM_PACKAGES_FOLDER="${HOME}/osm-packages"
export OKA_FOLDER="${OSM_PACKAGES_FOLDER}/oka/apps"
osm oka-add jenkins ${OKA_FOLDER}/jenkins --description jenkins --profile-type app-profile
osm oka-add testapp ${OKA_FOLDER}/testapp --description testapp --profile-type app-profile
osm oka-add testacme ${OKA_FOLDER}/testacme --description testacme --profile-type app-profile
osm oka-list
When the OKA is created, the field resourceState should be READY.
OKA deletion
osm oka-delete testapp
osm oka-delete testacme
osm oka-delete jenkins
OKA generation for helm charts
osm oka-generate jenkins --base-directory okas --profile-type app-profile --helm-repo-name bitnamicharts --helm-repo-url oci://registry-1.docker.io/bitnamicharts --helm-chart jenkins --version 13.4.20 --namespace jenkins
tree okas/jenkins
# Once generated, you can add it with:
osm oka-add jenkins okas/jenkins --description jenkins --profile-type app-profile
Profile operations
Listing profiles
osm profile-list
KSU operations
KSU creation from OKA
You must specify the destination profile:
export OSM_PACKAGES_FOLDER="${HOME}/osm-packages"
export OKA_FOLDER="${OSM_PACKAGES_FOLDER}/oka/apps"
osm ksu-create --ksu testapp --profile mydemo --profile-type app-profile --oka testapp --params ${OKA_FOLDER}/testapp-params.yaml
osm ksu-create --ksu testacme --profile mydemo --profile-type app-profile --oka testacme --params ${OKA_FOLDER}/testacme-params.yaml
osm ksu-create --ksu jenkins --description "Jenkins" --profile mydemo --profile-type app-profile --oka jenkins --params ${OKA_FOLDER}/jenkins-params.yaml
osm ksu-list
When the KSU is created, the field resourceState should be READY.
KSU deletion
osm ksu-delete testapp
osm ksu-delete testacme
osm ksu-delete jenkins