From 5689061140f4a24128fdfc4e6d0909db2f00c072 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Thu, 9 Jan 2025 16:04:45 +0100 Subject: [PATCH 1/2] Features 10923-10926: documentation for advanced cluster management Signed-off-by: garciadeblas --- advanced-cluster-management.md | 139 +++++++++++++++++++++++++++++++++ index.md | 2 + index.rst | 1 + navigation.md | 1 + 4 files changed, 143 insertions(+) create mode 100644 advanced-cluster-management.md diff --git a/advanced-cluster-management.md b/advanced-cluster-management.md new file mode 100644 index 0000000..a9b3f55 --- /dev/null +++ b/advanced-cluster-management.md @@ -0,0 +1,139 @@ +# Advanced cluster management with OSM client + +## OSM client initialization + +```bash +export OSM_GUI_URL=$(kubectl get -n osm -o jsonpath="{.spec.rules[0].host}" ingress ngui-ingress) +echo "OSM UI: $OSM_GUI_URL" +export OSM_HOSTNAME=$(kubectl get -n osm -o jsonpath="{.spec.rules[0].host}" ingress nbi-ingress) +echo "OSM_HOSTNAME (for osm client): $OSM_HOSTNAME" +``` + +## VIM target 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, tenant arquitecturait, subscription 1, and OSM-CTIO resource group" \ + --creds ${OSM_CREDS_FOLDER}/azure-credentials.json \ + --config "{region_name: westeurope, resource_group: 'OSM-CTIO', 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: + +```bash +az ad sp create-for-rbac --role Contributor --scopes /subscriptions//resourceGroups/ +``` + +## Cluster creation + +```bash +CLUSTER_NAME=cluster1 +CLUSTER_VM_SIZE=Standard_D2_v2 +CLUSTER_NODES=1 +REGION_NAME=northeurope +VIM_ACCOUNT=azure-site +RESOURCE_GROUP=OSM-CTIO +KUBERNETES_VERSION="1.30" +osm cluster-create --node-count ${CLUSTER_NODES} --node-size ${CLUSTER_VM_SIZE} --version ${KUBERNETES_VERSION} --vim-account ${VIM_ACCOUNT} --description "Gerardo cluster" ${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`. Everything in the tmux upper left screen will be in green. + +## Getting kubeconfig + +Once the cluster is ready, you can get the credentials in this way: + +```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 addition + +```bash +export OSM_PACKAGES_FOLDER="${HOME}/osm-packages" +osm oka-add hello-world ${OSM_PACKAGES_FOLDER}/oka/apps/hello-world --description "Hello World" +``` + +## Listing profiles + +```bash +osm profile-list +``` + +## KSU creation from OKA + +You must specify the destination profile: + +```bash +# Without params +osm ksu-create --ksu dashboard --description "Kubernetes Dashboard" --profile cluster1 --profile-type app-profile --oka hello-world +# With params +osm ksu-create --ksu dashboard --description "Kubernetes Dashboard" --profile cluster1 --profile-type app-profile --oka hello-world --params hello-world-params.yaml +``` + +## Cluster deletion + +```bash +CLUSTER_NAME=cluster1 +osm cluster-delete ${CLUSTER_NAME} +``` + +## VIM deletion + +```bash +osm vim-delete azure-site +``` + diff --git a/index.md b/index.md index 74087da..0268f87 100644 --- a/index.md +++ b/index.md @@ -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) diff --git a/index.rst b/index.rst index 23f256a..167a893 100644 --- a/index.rst +++ b/index.rst @@ -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 diff --git a/navigation.md b/navigation.md index a9678f4..9f39d29 100644 --- a/navigation.md +++ b/navigation.md @@ -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) -- GitLab From 79235baa54c6551b6eb6c8841c54a7e5c6415a0c Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Thu, 13 Feb 2025 11:59:53 +0100 Subject: [PATCH 2/2] Update documentation related to infra and app mgmt with OSm declarative framework Signed-off-by: garciadeblas --- advanced-cluster-management.md | 108 ++++++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 30 deletions(-) diff --git a/advanced-cluster-management.md b/advanced-cluster-management.md index a9b3f55..706f694 100644 --- a/advanced-cluster-management.md +++ b/advanced-cluster-management.md @@ -1,15 +1,19 @@ -# Advanced cluster management with OSM client +# Advanced cluster management -## OSM client initialization +## 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_GUI_URL=$(kubectl get -n osm -o jsonpath="{.spec.rules[0].host}" ingress ngui-ingress) -echo "OSM UI: $OSM_GUI_URL" export OSM_HOSTNAME=$(kubectl get -n osm -o jsonpath="{.spec.rules[0].host}" ingress nbi-ingress) -echo "OSM_HOSTNAME (for osm client): $OSM_HOSTNAME" +echo "OSM_HOSTNAME: $OSM_HOSTNAME" ``` -## VIM target registration +### VIM/Cloud account operations + +#### VIM/Cloud account registration Example for Azure: @@ -19,9 +23,9 @@ 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, tenant arquitecturait, subscription 1, and OSM-CTIO resource group" \ + --description "AZURE site" \ --creds ${OSM_CREDS_FOLDER}/azure-credentials.json \ - --config "{region_name: westeurope, resource_group: 'OSM-CTIO', subscription_id: '$AZURE_SUBSCRIPTION_ID', vnet_name: 'osm', flavors_pattern: '^Standard'}" + --config "{region_name: westeurope, resource_group: '', subscription_id: '$AZURE_SUBSCRIPTION_ID', vnet_name: 'osm', flavors_pattern: '^Standard'}" ``` File `${OSM_CREDS_FOLDER}/azure-env.rc`: @@ -56,7 +60,15 @@ The JSON credentials file corresponds to the service principal credentials obtai az ad sp create-for-rbac --role Contributor --scopes /subscriptions//resourceGroups/ ``` -## Cluster creation +#### VIM/Cloud account deletion + +```bash +osm vim-delete azure-site +``` + +### Cluster operations + +#### Cluster creation ```bash CLUSTER_NAME=cluster1 @@ -64,26 +76,37 @@ CLUSTER_VM_SIZE=Standard_D2_v2 CLUSTER_NODES=1 REGION_NAME=northeurope VIM_ACCOUNT=azure-site -RESOURCE_GROUP=OSM-CTIO +RESOURCE_GROUP= KUBERNETES_VERSION="1.30" -osm cluster-create --node-count ${CLUSTER_NODES} --node-size ${CLUSTER_VM_SIZE} --version ${KUBERNETES_VERSION} --vim-account ${VIM_ACCOUNT} --description "Gerardo cluster" ${CLUSTER_NAME} --region-name ${REGION_NAME} --resource-group ${RESOURCE_GROUP} +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`. Everything in the tmux upper left screen will be in green. +When the cluster is created, the field `resourceState` should be `READY`. -## Getting kubeconfig +#### 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 +#### Cluster registration This should be run over a cluster that was not created by OSM: @@ -93,47 +116,72 @@ VIM_ACCOUNT=azure-site osm cluster-register --creds ~/kubeconfig-${CLUSTER_NAME}.yaml --vim ${VIM_ACCOUNT} --description "My existing K8s cluster" ${CLUSTER_NAME} ``` -## Cluster scale +#### Cluster scale ```bash CLUSTER_NAME=cluster1 osm cluster-scale ${CLUSTER_NAME} --node-count 2 ``` -## OKA addition +### 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" -osm oka-add hello-world ${OSM_PACKAGES_FOLDER}/oka/apps/hello-world --description "Hello World" +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 ``` -## Listing profiles +### Profile operations + +#### Listing profiles ```bash osm profile-list ``` -## KSU creation from OKA +### KSU operations + +#### KSU creation from OKA You must specify the destination profile: ```bash -# Without params -osm ksu-create --ksu dashboard --description "Kubernetes Dashboard" --profile cluster1 --profile-type app-profile --oka hello-world -# With params -osm ksu-create --ksu dashboard --description "Kubernetes Dashboard" --profile cluster1 --profile-type app-profile --oka hello-world --params hello-world-params.yaml +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 ``` -## Cluster deletion - ```bash -CLUSTER_NAME=cluster1 -osm cluster-delete ${CLUSTER_NAME} +osm ksu-list ``` -## VIM deletion +When the KSU is created, the field `resourceState` should be `READY`. + +#### KSU deletion ```bash -osm vim-delete azure-site +osm ksu-delete testapp +osm ksu-delete testacme +osm ksu-delete jenkins ``` - -- GitLab