Commit b4df6885 authored by garciadeblas's avatar garciadeblas
Browse files

Merge branch 'feature10923' into 'master'

Features 10923-10926: documentation for advanced cluster management

See merge request !158
parents 96a8e518 65777cf9
Loading
Loading
Loading
Loading
Loading
+187 −0
Original line number Diff line number Diff line
# 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

```bash
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

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 \
    --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`:

```bash
export AZURE_CLIENT_ID="**********************************"
export AZURE_TENANT="**********************************"
export AZURE_SECRET="**********************************"
export AZURE_SUBSCRIPTION_ID="**********************************"
```

File `${OSM_CREDS_FOLDER}/azure-credentials.json`:

```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>

```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 -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-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}
```

#### Cluster scale

```bash
CLUSTER_NAME=cluster1
osm cluster-scale ${CLUSTER_NAME} --node-count 2
```

### OKA operations

#### OKA addition

```bash
# 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
```

```bash
osm oka-list
```

When the OKA is created, the field `resourceState` should be `READY`.

#### OKA deletion

```bash
osm oka-delete testapp
osm oka-delete testacme
osm oka-delete jenkins
```

### Profile operations

#### Listing profiles

```bash
osm profile-list
```

### KSU operations

#### KSU creation from OKA

You must specify the destination profile:

```bash
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
```

```bash
osm ksu-list
```

When the KSU is created, the field `resourceState` should be `READY`.

#### KSU deletion

```bash
osm ksu-delete testapp
osm ksu-delete testacme
osm ksu-delete jenkins
```
+2 −0
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@
   - How to setup a VIM to use it from OSM
5. [OSM Usage](05-osm-usage.md)
   - Learn how to run common OSM operations
5. [Advanced cluster management](advanced-cluster-management.md)
   - Learn how to run new OSM operations for advanced cluster management
6. [OSM platform configuration](06-osm-platform-configuration.md)
   - Setting up your OSM
7. [What to read next](07-what-to-read-next.md)
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ Welcome to Open Source MANO's documentation!
   03-installing-osm
   04-vim-setup
   05-osm-usage
   advanced-cluster-management
   06-osm-platform-configuration
   07-what-to-read-next
   08-how-to-contribute-to-docs
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
[Installing OSM](03-installing-osm.md)
[VIM(s) setup](04-vim-setup.md)
[OSM Usage](05-osm-usage.md)
[Advanced cluster management](advanced-cluster-management.md)
[OSM platform configuration](06-osm-platform-configuration.md)
[What to read next](07-what-to-read-next.md)
[How to contribute to documentation](08-how-to-contribute-to-docs.md)