Brian's cheatsheet for Helm commands: K8S / helm basic commands for ONAP integration
#git pull inn OOM
Yangs-MacBook-Air:oom yang$ git submodule update --init --recursive Yangs-MacBook-Air:oom yang$ git pull
#find all unreleased ONAP images used by OOM charts
Yangs-MacBook-Air:oom yang$ find . -name 'values.yaml' -exec grep -Hn image {} \; | grep onap | grep image | grep -E -i "staging|snapshot" | grep -v helm | sort ./kubernetes/aai/charts/aai-elasticsearch/values.yaml:22:image: onap/elasticsearch-sg:1.4-STAGING-latest
#ONAP installation from Windriver jumpserver. Git clone integration repo or pull the latest from repo first, then
xuyang11@pod-onap-01-vjhost:~$ cd integration/ xuyang11@pod-onap-01-vjhost:~/src/integration$ git pull xuyang11@pod-onap-01-vjhost:~/src/integration$ source deployment/heat/onap-oom/env/windriver/Integration-SB-XX-openrc xuyang11@pod-onap-01-vjhost:~/src/integration$ cd deployment/heat/onap-oom xuyang11@pod-onap-01-vjhost:~/src/integration/deployment/heat/onap-oom$ nohup ./scripts/deploy.sh -m docker-manifest-staging.csv -q env/windriver/onap-oom.env & or xuyang11@pod-onap-01-vjhost:~/src/integration/deployment/heat/onap-oom$ nohup ./scripts/deploy.sh -m docker-manifest.csv -q env/windriver/onap-oom.env &
#Update a project configuration or simply restart a project. For example, change GLOBAL_AAI_USERNAME parameter in integration_robot_properties.py
root@onap-oom-rancher:~# cd oom/kubernetes root@onap-oom-rancher:~/oom/kubernetes# helm list -a root@onap-oom-rancher:~/oom/kubernetes# helm delete dev-robot --purge root@onap-oom-rancher:~/oom/kubernetes# ~/integration/deployment/heat/onap-oom/scripts/cleanup.sh robot #clean up any resource used by robot root@onap-oom-rancher:~/oom/kubernetes# rm -rf /dockerdata-nfs/dev-robot #clean up the persistent data root@onap-oom-rancher:~/oom/kubernetes# vi robot/resources/config/eteshare/config/integration_robot_properties.py #make change to charts root@onap-oom-rancher:~/oom/kubernetes# make robot root@onap-oom-rancher:~/oom/kubernetes# make onap root@onap-oom-rancher:~/oom/kubernetes# helm deploy dev local/onap -f /root/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f /root/integration-override.yaml --namespace onap
#Undeploy the whole ONAP (not tested yet) - use 'kubectl -n onap get all' and then delete any dangling parts like below
root@rancher: helm undeploy dev --purge root@rancher: kubectl -n onap get all root@rancher: kubectl -n onap delete services --all root@rancher: kubectl -n onap delete pv --all root@rancher: kubectl -n onap delete pvc --all root@rancher: kubectl -n onap delete secrets --all root@rancher: kubectl -n onap delete clusterrolebinding --all root@rancher: kubectl -n onap delete statefulsets --all root@rancher: kubectl -n onap delete deployments --all root@rancher: kubectl -n onap delete job --all root@rancher: kubectl -n onap delete pods --all root@rancher: kubectl -n onap get all
#Deploy and undeploy a chart. See OOM Helm (un)Deploy plugins
root@oom-rancher:~/oom/kubernetes# helm deploy dev-sdc local/onap --namespace onap -f /root/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f /root/integration-override.yaml --verbose
If it fails, try to delete the release, and deploy again
root@oom-rancher:~/oom/kubernetes# helm deploy dev-sdc local/onap --namespace onap -f /root/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f /root/integration-override.yaml --verbose fetching local/onap Error: UPGRADE FAILED: "dev-sdc" has no deployed releases root@oom-rancher:~/oom/kubernetes# helm del dev-sdc --purge release "dev-sdc" deleted root@oom-rancher:~/oom/kubernetes# helm deploy dev-sdc local/onap --namespace onap -f /root/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f /root/integration-override.yaml --verbose fetching local/onap Release "dev-sdc" does not exist. Installing it now. NAME: dev-sdc
#Another way to install one chart (deprecated due to memory size limit of configmap)
root@oom-rancher:~/oom/kubenetes# helm delete --purge dev-sdc root@oom-rancher:~/oom/kubenetes# helm install local/sdc --namespace onap --name dev-sdc -f /root/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f /root/integration-override.yaml
#Edit deployment. Very useful to change deployment parameters, like docker image version so you can pick a previous working docker image. K8S will restart the pod after the change is made
root@onap-oom-rancher:~# kubectl edit deploy -n onap dev-sdc-sdc-fe
#Edit statefulset. Sometimes image version is in statefulset, use describe pod command and search for Controlled by keyword. You need to bounce pod after change
root@oom-rancher:~/oom/kubernetes# kubectl -n onap edit statefulset dev-appc-appc
#Find AAI endpoint IP and port. IP can be ANY cluster node IP, and port is 30233
root@onap-oom-rancher:/# kubectl -n onap get service |grep aai aai NodePort 10.43.125.58 <none> 8080:30232/TCP,8443:30233/TCP 16h aai-babel NodePort 10.43.148.198 <none> 9516:30279/TCP 16h aai-cassandra ClusterIP None <none> 9042/TCP,9160/TCP,61621/TCP 16h aai-champ NodePort 10.43.117.162 <none> 9522:30278/TCP 16h. ... ...
#List all pods
root@onap-oom-rancher:~# kubectl -n onap get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE dep-config-binding-service-6f68756fb8-h572p 2/2 Running 0 7h 10.42.223.154 onap-oom-k8s-5 dev-aaf-cm-5455cfd7c8-lzkpm 0/1 Init:1/2 0 9h 10.42.151.249 onap-oom-k8s-3 dev-aaf-cs-7586975b98-fvgrf 0/1 ContainerCreating 0 9h <none> onap-oom-k8s-1
#Check container log. First find containers in the pod
root@onap-oom-rancher:~# kubectl -n onap get pods dev-aai-cassandra-0 -o jsonpath={.spec.containers[*].name} aai-cassandra root@onap-oom-rancher:~# kubectl -n onap logs dev-aai-cassandra-0 aai-cassandra
#Restart a pod by deleting it and let Helm to restart one automatically
root@onap-oom-rancher:~/oom/kubernetes/onap/charts# kubectl -n onap delete pod dev-portal-portal-cassandra-7b4dbd599b-vhl54 root@onap-oom-rancher:~/oom/kubernetes/onap/charts#
#Delete a pod with force
root@oom-rancher:~# kubectl -n onap delete --grace-period=0 --force pod dev-so-so-monitoring-c8cc74547-znnwx
#Enter pod shell
root@onap-oom-rancher:~# kubectl -n onap exec -it dev-aai-cassandra-0 /bin/bash root@dev-aai-cassandra-0:/#
#Access ONAP portal. Get portal-app service private ip first, then go to Openstack Horizon to find public ip and update /etc/hosts with the public ip - see Mandeep Khinda s https://onap.readthedocs.io/en/latest/submodules/oom.git/docs/oom_user_guide.html#accessing-the-onap-portal-using-oom-and-a-kubernetes-cluster
# Get portal-app service private ip root@oom-rancher:~# kubectl -n onap get services |grep "portal-app" portal-app LoadBalancer 10.43.138.237 10.0.0.10 8989:30215/TCP,8006:30213/TCP,8010:30214/TCP 16h # Get public ip associated with the above private ip from Openstack xuyang11@pod-onap-01-vjhost:~/Integration-SB-05$ source Integration-SB-05-openrc.sh xuyang11@pod-onap-01-vjhost:~/Integration-SB-05$ openstack server list |grep 10.0.0.10 | b3ecfaac-4654-4b9f-ae33-41b296356384 | oom-k8s_1 | ACTIVE | oam_network_miiM=10.0.0.10, 10.12.5.78 | ubuntu-16-04-cloud-amd64 | # Update your local /etc/hosts Yangs-MacBook-Air:Downloads yang$ cat /etc/hosts 10.12.5.78 portal.api.simpledemo.onap.org 10.12.5.78 vid.api.simpledemo.onap.org 10.12.5.78 sdc.api.fe.simpledemo.onap.org 10.12.5.78 portal-sdk.simpledemo.onap.org 10.12.5.78 policy.api.simpledemo.onap.org 10.12.5.78 aai.api.sparky.simpledemo.onap.org 10.12.5.78 cli.api.simpledemo.onap.org 10.12.5.78 msb.api.discovery.simpledemo.onap.org # Use browser to access ONAP portal url http://portal.api.simpledemo.onap.org:8989/ONAPPORTAL/login.htm
#Copy files to and from a pod
root@oom-rancher:~/oom/kubernetes/robot# kubectl -n onap cp values.yaml dev-robot-598bcc6695-4fsh7: root@oom-rancher:~/oom/kubernetes/robot# kubectl -n onap cp dev-robot-598bcc6695-4fsh7:values.yaml /tmp/values.yaml
#Execute a command remotely
root@oom-rancher:~/oom/kubernetes/robot# kubectl -n onap exec dev-robot-598bcc6695-4fsh7 -- ls -l total 76 drwxr-xr-x 2 root root 4096 May 31 21:15 bin drwxr-xr-x 2 root root 4096 Apr 24 08:34 boot
#ONAP Healthcheck from Rancher VM
root@oom-rancher:~# cd oom/kubernetes/robot/ root@oom-rancher:~/oom/kubernetes/robot# ./ete-k8s.sh onap health
#Get the pod configMap
root@oom-rancher:~# kubectl -n onap get configMap dev-so-so-sdc-controller-app-configmap -o yaml apiVersion: v1 data: override.yaml: | # Copyright © 2018 AT&T USA # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. aai: auth: 2630606608347B7124C244AB0FE34F6F server: port: 8085 spring: security: usercredentials: - username: asdc password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' role: Asdc-Client - username: mso_admin password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' role: ACTUATOR mso: msoKey: 07a7159d3bf51a0e53be7a8f89699be7 logPath: ./logs/sdc catalog: db: spring: endpoint: http://so-catalog-db-adapter.onap:8082 db: auth: Basic YnBlbDpwYXNzd29yZDEk site-name: onapheat aai: endpoint: https://aai.onap:8443 asdc-connections: asdc-controller1: user: mso consumerGroup: sdc-OpenSource-Env1 consumerId: sdc-COpenSource-Env11 environmentName: AUTO asdcAddress: sdc-be.onap:8443 password: 613AF3483E695524F9857643B697FA51C7A9A0951094F53791485BF3458F9EADA37DBACCCEBD0CB242B85B4062745247 pollingInterval: 60 pollingTimeout: 60 relevantArtifactTypes: HEAT,HEAT_ENV,HEAT_VOL activateServerTLSAuth: false keyStorePassword: keyStorePath: watchDogTimeout: 300 isFitlerInEmptyResources: true ... ...
#Edit ConfigMap - e.g. chaning user name or password. Then you need to delete the pod and let k8s restart the pod to take the new values
root@oom-rancher:~# kubectl -n onap edit configmap dev-so-so-bpmn-infra-app-configmap ## Edit something in the config ## Delete Pod and let kubernetes respawn with new config root@oom-rancher:~# kubectl -n onap delete pod dev-so-so-bpmn-infra-5887f8c6c8-jkk7c
#Add a NodePort for debug/dev purposes
## Replace service name below root@oom-rancher:~# kubectl patch svc -n onap so-openstack-adapter --type='json' -p '[{"op":"replace","path":"/spec/type","value":"NodePort"}]' ## get nodeport assigned by kubernetes root@oom-rancher:~# kubectl -n onap get service | grep so-openstack-adapter so-openstack-adapter NodePort 10.43.105.9 <none> 8087:32715/TCP
#Generate encrypted openstack password
>echo -n <tenant_password>| openssl aes-128-ecb -e -K aa3871669d893c7fb8abbcda31b88b4f -nosalt | xxd -c 256 -p