This guide contains OSM client commands to operate infrastructure and applications following the new declarative framework introduced in Release SIXTEEN.
### OSM client initialization
```bash
export OSM_HOSTNAME=$(kubectl get -n osm -ojsonpath="{.spec.rules[0].host}" ingress nbi-ingress)
echo"OSM_HOSTNAME: $OSM_HOSTNAME"
```
### VIM/Cloud account operations
#### VIM/Cloud account registration
Example for Azure:
```bash
export OSM_CREDS_FOLDER="${HOME}/vims"
source${OSM_CREDS_FOLDER}/azure-env.rc
osm vim-create --name azure-site --account_type azure \
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>
```bash
az ad sp create-for-rbac --role Contributor --scopes /subscriptions/<subscription-id>/resourceGroups/<resource-group-name>
```
#### VIM/Cloud account deletion
```bash
osm vim-delete azure-site
```
### Cluster operations
#### Cluster creation
```bash
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}
```
```bash
osm cluster-list
```
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:
```bash
osm cluster-show cluster1 -ojsonpath='{.credentials}' | yq -P
# Save them in a file
osm cluster-show cluster1 -ojsonpath='{.credentials}' | yq -P> ~/kubeconfig-cluster1.yaml
# Test it
export KUBECONFIG=~/kubeconfig-mydemo.yaml
kubectl get nodes
```
In case credentials are renewed by the cloud policy, credentials can be obtained using any of the
```bash
osm cluster-get-credentials cluster1
```
#### Cluster registration
This should be run over a cluster that was not created by OSM:
```bash
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}