From 47df6c4696165cdba48829a8e2d5bb60a75d8b06 Mon Sep 17 00:00:00 2001 From: calvinosanc1 Date: Mon, 13 Jul 2020 07:46:52 +0200 Subject: [PATCH] K8s_01-Robot tests packages Signed-off-by: calvinosanc1 --- k8s_juju_ns/README.md | 159 ++++ k8s_juju_ns/bundle/bundle.yaml | 133 +++ k8s_juju_ns/icons/osm.png | Bin 0 -> 55888 bytes k8s_juju_ns/k8s_juju_nsd.yaml | 43 + k8s_jujucontroller_vnf/README | 3 + .../charms/tid-jujuk8s/.build.manifest | 566 +++++++++++ .../charms/tid-jujuk8s/LICENSE | 202 ++++ .../charms/tid-jujuk8s/Makefile | 24 + .../charms/tid-jujuk8s/README.md | 268 ++++++ .../charms/tid-jujuk8s/actions.yaml | 231 +++++ .../charms/tid-jujuk8s/actions/add-machine | 34 + .../charms/tid-jujuk8s/actions/add-machines | 34 + .../charms/tid-jujuk8s/actions/add-repo | 34 + .../charms/tid-jujuk8s/actions/delete-release | 34 + .../charms/tid-jujuk8s/actions/deploy-bundle | 34 + .../tid-jujuk8s/actions/generate-ssh-key | 33 + .../tid-jujuk8s/actions/get-ssh-public-key | 33 + .../charms/tid-jujuk8s/actions/init-helm | 34 + .../charms/tid-jujuk8s/actions/install-chart | 34 + .../tid-jujuk8s/actions/install-openebs-chart | 34 + .../actions/install-openebs-kubectl | 34 + .../charms/tid-jujuk8s/actions/post-deploy | 34 + .../charms/tid-jujuk8s/actions/reboot | 12 + .../tid-jujuk8s/actions/remove-machines | 34 + .../charms/tid-jujuk8s/actions/remove-repo | 34 + .../charms/tid-jujuk8s/actions/restart | 12 + .../tid-jujuk8s/actions/rollback-release | 34 + .../charms/tid-jujuk8s/actions/run | 33 + .../charms/tid-jujuk8s/actions/setup-juju | 34 + .../charms/tid-jujuk8s/actions/start | 12 + .../charms/tid-jujuk8s/actions/stop | 12 + .../tid-jujuk8s/actions/undeploy-bundle | 34 + .../charms/tid-jujuk8s/actions/upgrade | 12 + .../tid-jujuk8s/actions/upgrade-release | 34 + .../actions/verify-ssh-credentials | 33 + .../charms/tid-jujuk8s/bin/charm-env | 107 +++ .../charms/tid-jujuk8s/bin/layer_option | 22 + .../charms/tid-jujuk8s/config.yaml | 42 + .../charms/tid-jujuk8s/copyright | 16 + .../tid-jujuk8s/copyright.layer-options | 16 + .../charms/tid-jujuk8s/helm/elastic-data.yaml | 27 + .../tid-jujuk8s/helm/elastic-kibana.yaml | 5 + .../tid-jujuk8s/helm/elastic-master.yaml | 23 + .../tid-jujuk8s/helm/kafka-bitnami.yaml | 18 + .../charms/tid-jujuk8s/helm/nifi-cetic.yaml | 8 + .../tid-jujuk8s/helm/spark-bitnami.yaml | 49 + .../charms/tid-jujuk8s/hooks/collect-metrics | 68 ++ .../charms/tid-jujuk8s/hooks/config-changed | 22 + .../charms/tid-jujuk8s/hooks/hook.template | 22 + .../charms/tid-jujuk8s/hooks/install | 22 + .../charms/tid-jujuk8s/hooks/leader-elected | 22 + .../tid-jujuk8s/hooks/leader-settings-changed | 22 + .../tid-jujuk8s/hooks/post-series-upgrade | 22 + .../tid-jujuk8s/hooks/pre-series-upgrade | 22 + .../charms/tid-jujuk8s/hooks/start | 22 + .../charms/tid-jujuk8s/hooks/stop | 22 + .../charms/tid-jujuk8s/hooks/update-status | 22 + .../charms/tid-jujuk8s/hooks/upgrade-charm | 22 + .../charms/tid-jujuk8s/icon.svg | 279 ++++++ .../charms/tid-jujuk8s/layer.yaml | 16 + .../tid-jujuk8s/lib/charms/layer/__init__.py | 60 ++ .../tid-jujuk8s/lib/charms/layer/basic.py | 286 ++++++ .../tid-jujuk8s/lib/charms/layer/execd.py | 114 +++ .../tid-jujuk8s/lib/charms/layer/options.py | 26 + .../charms/tid-jujuk8s/lib/charms/sshproxy.py | 244 +++++ .../charms/tid-jujuk8s/metadata.yaml | 25 + .../charms/tid-jujuk8s/reactive/__init__.py | 0 .../charms/tid-jujuk8s/reactive/sshproxy.py | 210 +++++ .../tid-jujuk8s/reactive/tid-jujuk8s.py | 699 ++++++++++++++ .../charms/tid-jujuk8s/reactive/vnfproxy.py | 89 ++ .../charms/tid-jujuk8s/requirements.txt | 2 + .../charms/tid-jujuk8s/scripts/add-machine.sh | 4 + .../charms/tid-jujuk8s/scripts/add-repo.sh | 6 + .../tid-jujuk8s/scripts/bundle-4machines.yaml | 134 +++ .../tid-jujuk8s/scripts/bundle-empty.yaml | 115 +++ .../charms/tid-jujuk8s/scripts/bundle.yaml | 113 +++ .../tid-jujuk8s/scripts/delete-release.sh | 4 + .../charms/tid-jujuk8s/scripts/init-helm.sh | 11 + .../tid-jujuk8s/scripts/install-chart.sh | 9 + .../scripts/install-openebs-chart.sh | 5 + .../scripts/install-openebs-kubectl.sh | 5 + .../scripts/k8s-cloud-template.yaml | 4 + .../scripts/openebs-storage-class.yaml | 15 + .../charms/tid-jujuk8s/scripts/post-deploy.sh | 8 + .../tid-jujuk8s/scripts/remove-machine.sh | 2 + .../charms/tid-jujuk8s/scripts/remove-repo.sh | 5 + .../tid-jujuk8s/scripts/rollback-release.sh | 8 + .../charms/tid-jujuk8s/scripts/setup-juju.sh | 20 + .../tid-jujuk8s/scripts/test-elastic.sh | 38 + .../tid-jujuk8s/scripts/test-spark-pi.py | 29 + .../tid-jujuk8s/scripts/testNifiKafka.xml | 880 ++++++++++++++++++ .../tid-jujuk8s/scripts/undeploy-bundle.sh | 2 + .../tid-jujuk8s/scripts/upgrade-release.sh | 13 + .../charms/tid-jujuk8s/tests/00-setup | 5 + .../charms/tid-jujuk8s/tests/10-deploy | 35 + .../charms/tid-jujuk8s/version | 1 + .../wheelhouse/setuptools-41.6.0.zip | Bin 0 -> 852541 bytes .../cloud_init/cloud-config.txt | 14 + k8s_jujucontroller_vnf/icons/osm.png | Bin 0 -> 55888 bytes .../k8s_jujucontroller_vnfd.yaml | 173 ++++ k8s_jujumachine_vnf/README.md | 4 + .../cloud_init/cloud-config.txt | 5 + k8s_jujumachine_vnf/icons/osm.png | Bin 0 -> 55888 bytes k8s_jujumachine_vnf/k8s_jujumachine_vnfd.yaml | 32 + 104 files changed, 6757 insertions(+) create mode 100644 k8s_juju_ns/README.md create mode 100644 k8s_juju_ns/bundle/bundle.yaml create mode 100644 k8s_juju_ns/icons/osm.png create mode 100644 k8s_juju_ns/k8s_juju_nsd.yaml create mode 100644 k8s_jujucontroller_vnf/README create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/.build.manifest create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/LICENSE create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/Makefile create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/README.md create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions.yaml create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/add-machine create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/add-machines create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/add-repo create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/delete-release create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/deploy-bundle create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/generate-ssh-key create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/get-ssh-public-key create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/init-helm create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/install-chart create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/install-openebs-chart create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/install-openebs-kubectl create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/post-deploy create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/reboot create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/remove-machines create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/remove-repo create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/restart create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/rollback-release create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/run create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/setup-juju create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/start create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/stop create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/undeploy-bundle create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/upgrade create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/upgrade-release create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/verify-ssh-credentials create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/bin/charm-env create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/bin/layer_option create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/config.yaml create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/copyright create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/copyright.layer-options create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/elastic-data.yaml create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/elastic-kibana.yaml create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/elastic-master.yaml create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/kafka-bitnami.yaml create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/nifi-cetic.yaml create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/spark-bitnami.yaml create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/collect-metrics create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/config-changed create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/hook.template create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/install create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/leader-elected create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/leader-settings-changed create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/post-series-upgrade create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/pre-series-upgrade create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/start create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/stop create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/update-status create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/upgrade-charm create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/icon.svg create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/layer.yaml create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/layer/__init__.py create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/layer/basic.py create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/layer/execd.py create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/layer/options.py create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/sshproxy.py create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/metadata.yaml create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/__init__.py create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/sshproxy.py create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/tid-jujuk8s.py create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/vnfproxy.py create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/requirements.txt create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/add-machine.sh create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/add-repo.sh create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/bundle-4machines.yaml create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/bundle-empty.yaml create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/bundle.yaml create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/delete-release.sh create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/init-helm.sh create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/install-chart.sh create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/install-openebs-chart.sh create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/install-openebs-kubectl.sh create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/k8s-cloud-template.yaml create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/openebs-storage-class.yaml create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/post-deploy.sh create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/remove-machine.sh create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/remove-repo.sh create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/rollback-release.sh create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/setup-juju.sh create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/test-elastic.sh create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/test-spark-pi.py create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/testNifiKafka.xml create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/undeploy-bundle.sh create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/upgrade-release.sh create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/tests/00-setup create mode 100755 k8s_jujucontroller_vnf/charms/tid-jujuk8s/tests/10-deploy create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/version create mode 100644 k8s_jujucontroller_vnf/charms/tid-jujuk8s/wheelhouse/setuptools-41.6.0.zip create mode 100755 k8s_jujucontroller_vnf/cloud_init/cloud-config.txt create mode 100644 k8s_jujucontroller_vnf/icons/osm.png create mode 100644 k8s_jujucontroller_vnf/k8s_jujucontroller_vnfd.yaml create mode 100644 k8s_jujumachine_vnf/README.md create mode 100755 k8s_jujumachine_vnf/cloud_init/cloud-config.txt create mode 100644 k8s_jujumachine_vnf/icons/osm.png create mode 100644 k8s_jujumachine_vnf/k8s_jujumachine_vnfd.yaml diff --git a/k8s_juju_ns/README.md b/k8s_juju_ns/README.md new file mode 100644 index 00000000..11c615d1 --- /dev/null +++ b/k8s_juju_ns/README.md @@ -0,0 +1,159 @@ +# Onboarding and instantiation + +```bash +osm nfpkg-create k8s_base_vnf.tar.gz +osm nfpkg-create k8s_juju_vnf.tar.gz +osm nspkg-create k8s_base_ns.tar.gz +osm ns-create --ns_name k8s --nsd_name k8s_base --vim_account ost9-canonical-fortville --config '{vld: [ {name: mgmtnet, vim-network-name: mgmt} ] }' +``` + +This deploys a NS (k8s\_base\_ns) with one VNF that runs Juju (k8s\_juju\_vnf) and 4 VNFs (k8s\_base\_vnf) that run the K8s cluster (1 master, 3 workers). + +VMs will be called: + +- JUJU +- NODE1 +- NODE2 +- NODE3 +- NODE4 + +# Install and bootstrap of Juju in the VM where juju runs (JUJU) + +## Install juju + +```bash +sudo snap install juju --classic --channel=2.6/stable +ssh-keygen +``` + +## Add the cloud: manual provider type + +```bash +# Copy the ssh key locally +ssh-copy-id ubuntu@ +juju add-cloud + manual + k8s + ubuntu@ +``` + +## Create the controller + +```bash +ssh-copy-id -i /home/ubuntu/.local/share/juju/ssh/juju_id_rsa ubuntu@ +#The same as: cat /home/ubuntu/.local/share/juju/ssh/juju_id_rsa.pub >> .ssh/authorized_keys +juju bootstrap k8s jujuk8s +``` + +This creates a controller locally in the machine + +Juju status can be checked with: + +``` +juju status +``` + +# Add the VMs to juju (manual provider mode) + +First from JUJU you need to copy the controller SSH key to all nodes of the cluster (master and workers) + +```bash +#cat /home/ubuntu/.local/share/juju/ssh/juju_id_rsa.pub +#vi .ssh/authorized_keys +ssh-copy-id -i /home/ubuntu/.local/share/juju/ssh/juju_id_rsa ubuntu@ +ssh-copy-id -i /home/ubuntu/.local/share/juju/ssh/juju_id_rsa ubuntu@ +ssh-copy-id -i /home/ubuntu/.local/share/juju/ssh/juju_id_rsa ubuntu@ +ssh-copy-id -i /home/ubuntu/.local/share/juju/ssh/juju_id_rsa ubuntu@ +``` + +After that add the machines to juju controller mannually in JUJU: + +```bash +juju add-machine ssh:ubuntu@ --debug +juju add-machine ssh:ubuntu@ --debug +juju add-machine ssh:ubuntu@ --debug +juju add-machine ssh:ubuntu@ --debug +``` + +Next we look for the indentifiers of the machines and take notes of it. + +```bash +juju machines +``` + +If they are the first machines we add, then the ids will be 0, 1, 2, 3. + +# Deploy the K8s cluster with the bundle + +The original bundle cannot be used as it is because it assumes that it is going to be deployed in a cloud without specifying the machines. + +```bash +#juju deploy charmed-kubernetes +#wget https://api.jujucharms.com/charmstore/v5/charmed-kubernetes/archive/bundle.yaml +#vi bundle.yaml +``` + +The bundle has been edited to specify which application runs in which machine. + +We copy the bundle from osm-descriptors repo to JUJU: + +```bash +scp osm-descriptors/tid/k8s/k8s_base_ns/bundle/bundle.yaml ubuntu@ +``` + +Deploy the bundle and check the result: + +```bash +juju deploy ./bundle.yaml --map-machines=existing,0=0,1=1,2=2,3=3 +#juju deploy ./bundle.yaml --map-machines=existing,0=30,1=31,2=32,3=33 +juju status +``` + +# Interacting with the Kubernetes cluster + +In JUJU machine: + +```bash +mkdir -p ~/.kube +juju scp kubernetes-master/0:config ~/.kube/config +sudo snap install kubectl --classic +kubectl cluster-info +``` + +# To access the K8s dashboard + +In JUJU machine: + +```bash +juju config kubernetes-master enable-dashboard-addons=true +``` + +The dashboard could be accesible running this kubectl command: + +```bash +kubectl proxy --address +``` + +And now a SSH tunnel could be done from the PC to JUJU, and from the web browser access to the dashboard: + + + +# Install and init Helm + +## Install + +```bash +sudo snap install helm --classic +``` + +## Init + +```bash +# Optional. Create account for tiller +# kubectl --namespace kube-system create serviceaccount tiller +# kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller +helm init +# helm init --service-account tiller --wait +# kubectl --namespace kube-system patch deploy tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' +kubectl get all --all-namespaces +``` diff --git a/k8s_juju_ns/bundle/bundle.yaml b/k8s_juju_ns/bundle/bundle.yaml new file mode 100644 index 00000000..113e9ece --- /dev/null +++ b/k8s_juju_ns/bundle/bundle.yaml @@ -0,0 +1,133 @@ +description: A highly-available, production-grade Kubernetes cluster. +series: bionic +machines: + "0": + "1": + "2": + "3": +services: + containerd: + annotations: + gui-x: '475' + gui-y: '800' + charm: cs:~containers/containerd-20 + resources: {} + easyrsa: + annotations: + gui-x: '90' + gui-y: '420' + charm: cs:~containers/easyrsa-270 + constraints: root-disk=8G + num_units: 1 + resources: + easyrsa: 5 + to: + - "0" + etcd: + annotations: + gui-x: '800' + gui-y: '420' + charm: cs:~containers/etcd-449 + constraints: root-disk=8G + num_units: 3 + options: + channel: 3.2/stable + resources: + core: 0 + etcd: 3 + snapshot: 0 + to: + - "1" + - "2" + - "3" + flannel: + annotations: + gui-x: '475' + gui-y: '605' + charm: cs:~containers/flannel-438 + resources: + flannel-amd64: 394 + flannel-arm64: 390 + flannel-s390x: 377 + kubeapi-load-balancer: + annotations: + gui-x: '450' + gui-y: '250' + charm: cs:~containers/kubeapi-load-balancer-664 + constraints: root-disk=8G + expose: true + num_units: 1 + resources: {} + to: + - "0" + kubernetes-master: + annotations: + gui-x: '800' + gui-y: '850' + charm: cs:~containers/kubernetes-master-724 + constraints: cores=2 mem=4G root-disk=16G + num_units: 2 + options: + channel: 1.15/stable + resources: + cdk-addons: 0 + core: 0 + kube-apiserver: 0 + kube-controller-manager: 0 + kube-proxy: 0 + kube-scheduler: 0 + kubectl: 0 + to: + - "1" + - "2" + kubernetes-worker: + annotations: + gui-x: '90' + gui-y: '850' + charm: cs:~containers/kubernetes-worker-571 + constraints: cores=4 mem=4G root-disk=16G + expose: true + num_units: 3 + options: + channel: 1.15/stable + resources: + cni-amd64: 392 + cni-arm64: 383 + cni-s390x: 395 + core: 0 + kube-proxy: 0 + kubectl: 0 + kubelet: 0 + to: + - "1" + - "2" + - "3" +relations: +- - kubernetes-master:kube-api-endpoint + - kubeapi-load-balancer:apiserver +- - kubernetes-master:loadbalancer + - kubeapi-load-balancer:loadbalancer +- - kubernetes-master:kube-control + - kubernetes-worker:kube-control +- - kubernetes-master:certificates + - easyrsa:client +- - etcd:certificates + - easyrsa:client +- - kubernetes-master:etcd + - etcd:db +- - kubernetes-worker:certificates + - easyrsa:client +- - kubernetes-worker:kube-api-endpoint + - kubeapi-load-balancer:website +- - kubeapi-load-balancer:certificates + - easyrsa:client +- - flannel:etcd + - etcd:db +- - flannel:cni + - kubernetes-master:cni +- - flannel:cni + - kubernetes-worker:cni +- - containerd:containerd + - kubernetes-worker:container-runtime +- - containerd:containerd + - kubernetes-master:container-runtime diff --git a/k8s_juju_ns/icons/osm.png b/k8s_juju_ns/icons/osm.png new file mode 100644 index 0000000000000000000000000000000000000000..62012d2a2b491bdcd536d62c3c3c863c0d8c1b33 GIT binary patch literal 55888 zcmeHwcVN_2w*Q%4(|d0OLLi+Mnsh-yL{Y>ZASk;E3aIGrzPH8Qr`y-xuB*GQy6#gH z8?K0`bg9xyNCE*8l8|1f_uuDyCle;aWC)1v`-2OU`L= z(5#u$?!fmFe3mNZ_&Xtc#6$Q}Ju!3PDx%sQo4@$EA1*Fll77=f_4qYo(Z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_juju_ns/k8s_juju_nsd.yaml @@ -0,0 +1,43 @@ +nsd-catalog: + nsd: + - id: k8s_juju + name: k8s_juju + short-name: k8s_juju + description: NS consisting of a 4 k8s_jujumachine VNFs and 1 k8s_jujucontroller VNF connected to mgmt network + vendor: OSM + version: '1.0' + logo: osm.png + constituent-vnfd: + - member-vnf-index: k8s_vnf1 + vnfd-id-ref: k8s_jujumachine_vnf + - member-vnf-index: k8s_vnf2 + vnfd-id-ref: k8s_jujumachine_vnf + - member-vnf-index: k8s_vnf3 + vnfd-id-ref: k8s_jujumachine_vnf + - member-vnf-index: k8s_vnf4 + vnfd-id-ref: k8s_jujumachine_vnf + - member-vnf-index: k8s_juju + vnfd-id-ref: k8s_jujucontroller_vnf + vld: + - id: mgmtnet + name: mgmtnet + type: ELAN + mgmt-network: 'true' + vim-network-name: mgmt + vnfd-connection-point-ref: + - member-vnf-index-ref: k8s_vnf1 + vnfd-id-ref: k8s_jujumachine_vnf + vnfd-connection-point-ref: mgmt + - member-vnf-index-ref: k8s_vnf2 + vnfd-id-ref: k8s_jujumachine_vnf + vnfd-connection-point-ref: mgmt + - member-vnf-index-ref: k8s_vnf3 + vnfd-id-ref: k8s_jujumachine_vnf + vnfd-connection-point-ref: mgmt + - member-vnf-index-ref: k8s_vnf4 + vnfd-id-ref: k8s_jujumachine_vnf + vnfd-connection-point-ref: mgmt + - member-vnf-index-ref: k8s_juju + vnfd-id-ref: k8s_jujucontroller_vnf + vnfd-connection-point-ref: mgmt + diff --git a/k8s_jujucontroller_vnf/README b/k8s_jujucontroller_vnf/README new file mode 100644 index 00000000..faa5468f --- /dev/null +++ b/k8s_jujucontroller_vnf/README @@ -0,0 +1,3 @@ +This is a VNF with a single small VDU intended to run a juju controller +that will deploy a K8s cluster using a juju bundle on a set of machines. + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/.build.manifest b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/.build.manifest new file mode 100644 index 00000000..b697fe2d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/.build.manifest @@ -0,0 +1,566 @@ +{ + "layers": [ + { + "rev": "fcdcea4e5de3e1556c24e6704607862d0ba00a56", + "url": "layer:options" + }, + { + "rev": "1d2489bff56daf2f8d1c06ee9248bb0094e4ad49", + "url": "layer:basic" + }, + { + "rev": "29d9dd2e642048f84e1ac388e03756c6cdec3551", + "url": "layer:sshproxy" + }, + { + "rev": "e6a495fab012f06484ed419fd5c2453e6a92eef1", + "url": "layer:vnfproxy" + }, + { + "rev": "5891094f6efebc720bcc806a7784419abe5c892a", + "url": "tid-jujuk8s" + } + ], + "signatures": { + ".build.manifest": [ + "build", + "dynamic", + "unchecked" + ], + ".gitignore": [ + "layer:sshproxy", + "static", + "17526a7f7312e7eefb932d1c514b7bc8425fab5bd1ade149e106ecf8bff67358" + ], + "LICENSE": [ + "layer:basic", + "static", + "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30" + ], + "Makefile": [ + "layer:basic", + "static", + "b7ab3a34e5faf79b96a8632039a0ad0aa87f2a9b5f0ba604e007cafb22190301" + ], + "README.md": [ + "layer:vnfproxy", + "static", + "fed2909a56f740deec009fed50deffe9b017531a5ef6bcde6d2ec519e19d4014" + ], + "actions.yaml": [ + "tid-jujuk8s", + "dynamic", + "cd54801693ce9c48e2275e2d205974641784e25244971a4db76693c0240b8d93" + ], + "actions/add-machine": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/add-machines": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/add-repo": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/delete-release": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/deploy-bundle": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/generate-ssh-key": [ + "layer:sshproxy", + "static", + "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" + ], + "actions/get-ssh-public-key": [ + "layer:sshproxy", + "static", + "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" + ], + "actions/init-helm": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/install-chart": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/install-openebs-chart": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/install-openebs-kubectl": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/post-deploy": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/reboot": [ + "layer:vnfproxy", + "static", + "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" + ], + "actions/remove-machines": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/remove-repo": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/restart": [ + "layer:vnfproxy", + "static", + "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" + ], + "actions/rollback-release": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/run": [ + "layer:sshproxy", + "static", + "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" + ], + "actions/setup-juju": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/start": [ + "layer:vnfproxy", + "static", + "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" + ], + "actions/stop": [ + "layer:vnfproxy", + "static", + "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" + ], + "actions/undeploy-bundle": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/upgrade": [ + "layer:vnfproxy", + "static", + "afc0df4409fb6eb7b7e6595490913c1efe329b393d4860ae226d8aaccc01fcf2" + ], + "actions/upgrade-release": [ + "tid-jujuk8s", + "static", + "d24cace87faffae2500250abf7717bcfd81dffa2a8985bc13657826b7a76e7b0" + ], + "actions/verify-ssh-credentials": [ + "layer:sshproxy", + "static", + "46bf4be02078a0f5ac60ab81609372a8f9943885b7a4999ce5332ea2f4857036" + ], + "bin/charm-env": [ + "layer:basic", + "static", + "458c53532c19ee357cbf4209ccc7d811810718ba0ea3b0588b3d3ef040a44b8e" + ], + "bin/layer_option": [ + "layer:options", + "static", + "e959bf29da4c5edff28b2602c24113c4df9e25cdc9f2aa3b5d46c8577b2a40cc" + ], + "config.yaml": [ + "tid-jujuk8s", + "dynamic", + "6004ebea9161166b9a0c87bdced4770aaea71ff98831e032ba0c7bd633cdfa82" + ], + "copyright": [ + "layer:basic", + "static", + "f6740d66fd60b60f2533d9fcb53907078d1e20920a0219afce7182e2a1c97629" + ], + "copyright.layer-options": [ + "layer:options", + "static", + "f6740d66fd60b60f2533d9fcb53907078d1e20920a0219afce7182e2a1c97629" + ], + "helm/elastic-data.yaml": [ + "tid-jujuk8s", + "static", + "de9db1d8286743347b38e229987bcdd1c88304af094cd2a768a30f19c8ba8db5" + ], + "helm/elastic-kibana.yaml": [ + "tid-jujuk8s", + "static", + "ee069fe64512dad4de7145ab9da3863a533446da3a40419613d5ab532a5e1454" + ], + "helm/elastic-master.yaml": [ + "tid-jujuk8s", + "static", + "7544171333b5e47f914849bdb4638c558c73d1d3f0c6427625ead8c5779797b8" + ], + "helm/kafka-bitnami.yaml": [ + "tid-jujuk8s", + "static", + "4aed51ccb174ed96052912ad929c16eeafdee6b808051f8134c47ff38df5a92c" + ], + "helm/nifi-cetic.yaml": [ + "tid-jujuk8s", + "static", + "a56fe6ea3a48020f29da247518684571796f3216ee42f110858774c0756e8e9f" + ], + "helm/spark-bitnami.yaml": [ + "tid-jujuk8s", + "static", + "36e17c4d277fe028ed4fcb39467d82433adba6aaa519b0816ae24a2685c732ca" + ], + "hooks/collect-metrics": [ + "layer:vnfproxy", + "static", + "f2a6360cf21993f7dc07785ad702f141679a5a9b03c3db5d50dd06ffbe26bbb2" + ], + "hooks/config-changed": [ + "layer:basic", + "dynamic", + "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" + ], + "hooks/hook.template": [ + "layer:basic", + "static", + "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" + ], + "hooks/install": [ + "layer:basic", + "dynamic", + "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" + ], + "hooks/leader-elected": [ + "layer:basic", + "dynamic", + "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" + ], + "hooks/leader-settings-changed": [ + "layer:basic", + "dynamic", + "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" + ], + "hooks/post-series-upgrade": [ + "layer:basic", + "dynamic", + "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" + ], + "hooks/pre-series-upgrade": [ + "layer:basic", + "dynamic", + "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" + ], + "hooks/start": [ + "layer:basic", + "dynamic", + "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" + ], + "hooks/stop": [ + "layer:basic", + "dynamic", + "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" + ], + "hooks/update-status": [ + "layer:basic", + "dynamic", + "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" + ], + "hooks/upgrade-charm": [ + "layer:basic", + "dynamic", + "2b693cb2a11594a80cc91235c2dc219a0a6303ae62bee8aa87eb35781f7158f7" + ], + "icon.svg": [ + "tid-jujuk8s", + "static", + "d20624e9389af6506a8d8a69ac9bba4d41709601b624c0875fd7d6717b395088" + ], + "layer.yaml": [ + "tid-jujuk8s", + "dynamic", + "18aaafe36590b1b7d954cb65b042a60296dad86af760ec1c8d35d8c679774c89" + ], + "lib/charms/layer/__init__.py": [ + "layer:basic", + "static", + "dfe0d26c6bf409767de6e2546bc648f150e1b396243619bad3aa0553ab7e0e6f" + ], + "lib/charms/layer/basic.py": [ + "layer:basic", + "static", + "445652dbaa1f0b84a7215da185bcbdff097bb9bbbce11b4c2dbbff90f77719a9" + ], + "lib/charms/layer/execd.py": [ + "layer:basic", + "static", + "fda8bd491032db1db8ddaf4e99e7cc878c6fb5432efe1f91cadb5b34765d076d" + ], + "lib/charms/layer/options.py": [ + "layer:options", + "static", + "8ae7a07d22542fc964f2d2bee8219d1c78a68dace70a1b38d36d4aea47b1c3b2" + ], + "lib/charms/sshproxy.py": [ + "layer:sshproxy", + "static", + "fba0834f98f570b0b3d6b3e8a7f17b1d8909f50da9410ccda89b586f914b7ffd" + ], + "metadata.yaml": [ + "tid-jujuk8s", + "dynamic", + "77766673d555457570d19232797fb6d01e598ef20c325c96a54a97b8cc4c5348" + ], + "reactive/__init__.py": [ + "layer:basic", + "static", + "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + ], + "reactive/sshproxy.py": [ + "layer:sshproxy", + "static", + "acfaedf414946f8d218e5ebd04177f87258286915ba83b9c42ff7385975da6ab" + ], + "reactive/tid-jujuk8s.py": [ + "tid-jujuk8s", + "static", + "2ea9fde00640699891adee85b303aad00901ed1c682ff28be382ea3c86b82c98" + ], + "reactive/vnfproxy.py": [ + "layer:vnfproxy", + "static", + "8e4101a72f02832e5c233b731981ff483675be608321b8eb9743d605b3f7d77a" + ], + "requirements.txt": [ + "layer:basic", + "static", + "0f1c70d27e26005a96d66ad54482877ae20f7737693c833e29dd72bd6ac24892" + ], + "scripts/add-machine.sh": [ + "tid-jujuk8s", + "static", + "19798eea45157940114d36e360cab3f3e9eed47b594b9361b5b6ecf21842ecde" + ], + "scripts/add-repo.sh": [ + "tid-jujuk8s", + "static", + "b7c089422cff12bd7d4bcc6e5303abcdf52ca831067a2002804b6aec09f848fa" + ], + "scripts/bundle-4machines.yaml": [ + "tid-jujuk8s", + "static", + "cb789a4a5e6bb712a27b81a215e4bc23dd6b4cc23dc62b5c9ad4f0f75148bbb4" + ], + "scripts/bundle-empty.yaml": [ + "tid-jujuk8s", + "static", + "1bc216d8973e0aefdce00a68f80267ee9093a205bd76ac6ffc60ff236d38e47f" + ], + "scripts/bundle.yaml": [ + "tid-jujuk8s", + "static", + "e9c868c2ecdca84f19b54c625364cbbb1ede26c5eabf822950b29de72c8a3c65" + ], + "scripts/delete-release.sh": [ + "tid-jujuk8s", + "static", + "73aa2183f3913e7f51013dafbb14cd5779955c40d0e0ac77a3d2baf6e2cd8aca" + ], + "scripts/init-helm.sh": [ + "tid-jujuk8s", + "static", + "c8f6a55660c717c77fde22fa6c6d0197e630b449cb41a7ec28287e410fbc55e9" + ], + "scripts/install-chart.sh": [ + "tid-jujuk8s", + "static", + "bb0ff17a7000cf4b3e191aeaaef8caa216a6722c1c7d6c9c0a91cac609d4b89d" + ], + "scripts/install-openebs-chart.sh": [ + "tid-jujuk8s", + "static", + "caeecdc6069a48f1c1fd348fbdecfee8b2b01fe3fc0e2f1eff664f0db4cf7fcb" + ], + "scripts/install-openebs-kubectl.sh": [ + "tid-jujuk8s", + "static", + "5364ad5284915b7edd761a0b9708e313f76ff3ae98a35ef51e7c9227b764ecd1" + ], + "scripts/k8s-cloud-template.yaml": [ + "tid-jujuk8s", + "static", + "9e2343f5a27768af9dae44838351cca95474ec0ba9fe7791efe84c8c2b635a83" + ], + "scripts/openebs-storage-class.yaml": [ + "tid-jujuk8s", + "static", + "02a720019bb34ab89fa9d2fcb8da9d757f3c046ec5165e84af8dc3a85f5f1609" + ], + "scripts/post-deploy.sh": [ + "tid-jujuk8s", + "static", + "edacb68927c00f45879ba1312bb63eb398d8532cc9964f44f76d98a8fd72ae97" + ], + "scripts/remove-machine.sh": [ + "tid-jujuk8s", + "static", + "d9622fae2ab02fe359ed150964a92653697bfb235e20947aa3c3f385484e97bf" + ], + "scripts/remove-repo.sh": [ + "tid-jujuk8s", + "static", + "629cbb1ce65036170cf6e46f0dda1b72609055b749a830b8f274060713a0c08d" + ], + "scripts/rollback-release.sh": [ + "tid-jujuk8s", + "static", + "70dba456b3b7f6b1d02738294083f13dd43f3582ed1180a486546667bdea7415" + ], + "scripts/setup-juju.sh": [ + "tid-jujuk8s", + "static", + "5ecf257a6e6218f4ba7bf8c503147ba76f1a128df9caad80ab167d8ac61cdf44" + ], + "scripts/test-elastic.sh": [ + "tid-jujuk8s", + "static", + "50814381337d2f39215275067d15f0ceba3b9e0a56ad39ed79908588c18ba002" + ], + "scripts/test-spark-pi.py": [ + "tid-jujuk8s", + "static", + "866c6b5405b30a88d61d103c7b157328d1c321d7df68bfc294dc451bc023a3df" + ], + "scripts/testNifiKafka.xml": [ + "tid-jujuk8s", + "static", + "d3f41988516bef475d11e6e67765117892c72b595164925ae13e4b0d5668fb8a" + ], + "scripts/undeploy-bundle.sh": [ + "tid-jujuk8s", + "static", + "d9622fae2ab02fe359ed150964a92653697bfb235e20947aa3c3f385484e97bf" + ], + "scripts/upgrade-release.sh": [ + "tid-jujuk8s", + "static", + "d318575ad0ca243dfca6f251fe212501f0bf4e04f759d480ab97e0aaf6027024" + ], + "tests/00-setup": [ + "tid-jujuk8s", + "static", + "111c079b81d260bbcd716dcf41672372a4cf4aaa14154b6c3055deeedae37a06" + ], + "tests/10-deploy": [ + "tid-jujuk8s", + "static", + "042b110489b80ee9b5da765e31e58892ed77f98255de26cbc4646f98a5170195" + ], + "version": [ + "tid-jujuk8s", + "dynamic", + "3057645b724505c606b8471d5b8a541beea27e2881a946fd0f6015e5db46b517" + ], + "wheelhouse/Jinja2-2.10.3.tar.gz": [ + "layer:basic", + "dynamic", + "9fe95f19286cfefaa917656583d020be14e7859c6b0252588391e47db34527de" + ], + "wheelhouse/MarkupSafe-1.1.1.tar.gz": [ + "layer:basic", + "dynamic", + "29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b" + ], + "wheelhouse/PyYAML-5.3.tar.gz": [ + "layer:basic", + "dynamic", + "e9f45bd5b92c7974e59bcd2dcc8631a6b6cc380a904725fce7bc08872e691615" + ], + "wheelhouse/Tempita-0.5.2.tar.gz": [ + "layer:basic", + "dynamic", + "cacecf0baa674d356641f1d406b8bff1d756d739c46b869a54de515d08e6fc9c" + ], + "wheelhouse/charmhelpers-0.20.7.tar.gz": [ + "layer:basic", + "dynamic", + "e0f8d005d39cded1b0c5997d8ef1d90832341c67ebeb4a334ad1eb348fbd803a" + ], + "wheelhouse/charms.reactive-1.3.0.tar.gz": [ + "layer:basic", + "dynamic", + "82d2c614c82d64bf56e913990f22663e5de64b99db15838abfd9a064f1cc2f51" + ], + "wheelhouse/ecdsa-0.15.tar.gz": [ + "layer:sshproxy", + "dynamic", + "8f12ac317f8a1318efa75757ef0a651abe12e51fc1af8838fb91079445227277" + ], + "wheelhouse/netaddr-0.7.19.tar.gz": [ + "layer:basic", + "dynamic", + "38aeec7cdd035081d3a4c306394b19d677623bf76fa0913f6695127c7753aefd" + ], + "wheelhouse/paramiko-1.16.3.tar.gz": [ + "layer:sshproxy", + "dynamic", + "97d932fdb4fec9aadf6bea368123f3ee15b92199f92eb62666370c7fed62d072" + ], + "wheelhouse/pip-18.1.tar.gz": [ + "layer:basic", + "dynamic", + "c0a292bd977ef590379a3f05d7b7f65135487b67470f6281289a94e015650ea1" + ], + "wheelhouse/pyaml-19.12.0.tar.gz": [ + "layer:basic", + "dynamic", + "b3f636b467864319d7ded1558f86bb305b8612a274f5d443a62dc5eceb1b7176" + ], + "wheelhouse/pycrypto-2.6.1.tar.gz": [ + "layer:sshproxy", + "dynamic", + "f2ce1e989b272cfcb677616763e0a2e7ec659effa67a88aa92b3a65528f60a3c" + ], + "wheelhouse/setuptools-41.6.0.zip": [ + "layer:basic", + "dynamic", + "6afa61b391dcd16cb8890ec9f66cc4015a8a31a6e1c2b4e0c464514be1a3d722" + ], + "wheelhouse/setuptools_scm-1.17.0.tar.gz": [ + "layer:basic", + "dynamic", + "70a4cf5584e966ae92f54a764e6437af992ba42ac4bca7eb37cc5d02b98ec40a" + ], + "wheelhouse/six-1.13.0.tar.gz": [ + "layer:sshproxy", + "dynamic", + "30f610279e8b2578cab6db20741130331735c781b56053c59c4076da27f06b66" + ], + "wheelhouse/wheel-0.33.6.tar.gz": [ + "layer:basic", + "dynamic", + "10c9da68765315ed98850f8e048347c3eb06dd81822dc2ab1d4fde9dc9702646" + ] + } +} \ No newline at end of file diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/LICENSE b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/Makefile b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/Makefile new file mode 100644 index 00000000..a1ad3a5c --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/Makefile @@ -0,0 +1,24 @@ +#!/usr/bin/make + +all: lint unit_test + + +.PHONY: clean +clean: + @rm -rf .tox + +.PHONY: apt_prereqs +apt_prereqs: + @# Need tox, but don't install the apt version unless we have to (don't want to conflict with pip) + @which tox >/dev/null || (sudo apt-get install -y python-pip && sudo pip install tox) + +.PHONY: lint +lint: apt_prereqs + @tox --notest + @PATH=.tox/py34/bin:.tox/py35/bin flake8 $(wildcard hooks reactive lib unit_tests tests) + @charm proof + +.PHONY: unit_test +unit_test: apt_prereqs + @echo Starting tests... + tox diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/README.md b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/README.md new file mode 100644 index 00000000..9d4451e3 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/README.md @@ -0,0 +1,268 @@ +# vnfproxy + +A [Juju](https://jujucharms.com/) charm layer. See [how it works](https://jujucharms.com/how-it-works) and the [Getting Started](https://jujucharms.com/docs/stable/developer-getting-started) page for more information about Juju and Charms. + +[OSM](https://osm.etsi.org/) is an [ETSI](http://www.etsi.org/)-hosted project to develop an Open Source NFV Management and Orchestration (MANO) software stack aligned with ETSI NFV. + +## Overview + +The vnfproxy [layer](https://jujucharms.com/docs/stable/developer-layers) is intended for use by vendors who wish to integrate a VNF with OSM. The current release of OSM only supports a lightweight version of Juju charms, which we refer to as VNF Configuration or "proxy" charms. + +This document will describe the steps necessary to create a charm for your VNF. + +First, consider the diagram below: + +``` ++---------------------+ +---------------------+ +| <----+ | +| Resource | | Service | +| Orchestrator (RO) +----> Orchestrator (SO) | +| | | | ++------------------+--+ +-------+----^--------+ + | | | + | | | + | | | + +-----v-----+ +-v----+--+ + | <-------+ | + | Virtual | | Proxy | + | Machine | | Charm | + | +-------> | + +-----------+ +---------+ +``` + +The Virtual Machine (VM) is created by the Resource Orchestrator (RO), at the +request of the Service Orchestrator (SO). Once the VM has been created, a +"proxy charm" is deployed in order to facilitate operations between the SO and +your service running within the VM. + +As such, a proxy charm will expose a number of actions -- also known as service primitives -- that are run by the SO. By default, the following actions are exposed: + +```bash +actions +├── reboot +├── restart +├── run +├── start +├── stop +└── upgrade +``` + +Some actions, such as `run` and `reboot`, do not require any additional configuration. The rest, however, require you to implement the command(s) required to interact with your VNF. + +A charm is composed of multiple layers of code. The layer you create for your VNF is the topmost layer. It will include the basic layer, which provides the framework for building reactive charms, and the vnfproxy layer, which adds functionality specific to operating and configuring VNFs. Finally, these layers are combined to form the charm you'll place inside your VNF Descriptor Package. + +## Step 1: Create the layer for your proxy charm: + +Create a new charm layer, substituting "myvnf" with the name of your VNF. + +```bash +$ charm create myvnf +$ cd myvnf +``` + +Modify `layer.yaml` to the following: +```yaml +includes: + - layer:basic + - layer:vnfproxy +``` + +The `metadata.yaml` describes your service. It should look similar to the following: + +```yaml +name: myvnf +summary: My VNF provides a specific virtualized network function. +maintainer: Adam Israel +description: | + A longer description of your VNF and what it provides to users. +series: + - xenial +tags: + - osm + - vnf +subordinate: false +``` + +### Actions (Service Primitives) + +In Juju, Service Primitives are referred to as Actions. These are commands that will be executed on the VNF on request of the Service Orchestrator. + +#### Defining Actions + +Actions are defined through a yaml file called `actions.yaml` in the root directory of your charm. This file describes the action and the parameters it requires in order to execute. + +```yaml +configure-server: + description: "Configure a thing" + params: + polling-interval: + type: int + description: "The interval, in seconds, to poll a thing." + default: 30 + +``` +#### Implementing your Actions + +We use executable files in the charm's `actions/` directory to invoke a reactive handler for your VNF logic. Each file should have the same name as the action you defined in `actions.yaml`. + +Cut and paste the following into `actions/configure-server` and `chmod +x actions/configure-server`: + +```bash +#!/usr/bin/env python3 +import sys +sys.path.append('lib') + +from charms.reactive import main +from charms.reactive import set_state +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_state('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) +``` + +Next, we'll add the code that will be executed inside your VNF via the ssh credentials. Open `reactive/myvnf.py` and add the following reactive handler code: + +```python +# Change configure-server to match the name of the action you want to execute. +@when('actions.configure-server') +def configure_server(): + err = '' + try: + # Put the code here that you want to execute + cmd = "" + result, err = charms.sshproxy._run(cmd) + except: + action_fail('command failed:' + err) + else: + action_set({'output': result}) + finally: + remove_flag('actions.start') + +``` + +#### Default Actions (Service Primitives) + +The vnfproxy layer defines several default actions that you may implement. If you choose not to implement these, the actions will do nothing. + +Add the following code to `reactive/myvnf.py` and fill in the `cmd` variable with the command to be run on your VNF: + +```python +@when('actions.start') +def start(): + err = '' + try: + # Put the code here that you want to execute + cmd = "" + result, err = charms.sshproxy._run(cmd) + except: + action_fail('command failed:' + err) + else: + action_set({'output': result}) + finally: + remove_flag('actions.start') + + +@when('actions.stop') +def stop(): + err = '' + try: + # Enter the command to stop your service(s) + cmd = "service myname stop" + result, err = charms.sshproxy._run(cmd) + except: + action_fail('command failed:' + err) + else: + action_set({'output': result}) + finally: + remove_flag('actions.stop') + + +@when('actions.restart') +def restart(): + err = '' + try: + # Enter the command to restart your service(s) + cmd = "service myname restart" + result, err = charms.sshproxy._run(cmd) + except: + action_fail('command failed:' + err) + else: + action_set({'output': result}) + finally: + remove_flag('actions.restart') + + @when('actions.upgrade') + def upgrade_vnf(): + """Upgrade the software on the VNF. + + This action is intended to be used to perform software upgrades on a running VNF. + """ + err = '' + try: + # Enter the command (s) to upgrade your VNF software + cmd = "" + result, err = charms.sshproxy._run(cmd) + except: + action_fail('command failed:' + err) + else: + action_set({'output': result}) + finally: + remove_flag('actions.upgrade') +``` + +Rename `README.ex` to `README.md` and describe your application and its usage. + +### Configuration + +Charms support immutable configuration, defined by the `config.yaml` file. In the case of OSM, it's configuration is primarily driven through service primitives. Feel free to delete `config.yaml`. + +### Metrics + +Juju supports the polling of metrics. To do this, create the `metrics.yaml` file in the root directory of your charm, following the example below. The command specified will be executed inside your VNF; it should return a positive decimal number. The collected metrics will be made available to OSM, beginning with Release 4. + +```yaml +metrics: + uptime: + type: gauge + description: "Seconds since the machine was rebooted." + command: awk '{print $1}' /proc/uptime + +``` + +These metrics are collected automatically by way of the `collect-metrics` hook, are stored in the Juju Controller, and will be periodically polled by the OSM MON module. + +### Building your VNF charm + +Once you've implemented your actions, you need to compile the various charm layers. From the charm's root directory: +```bash +$ charm build +``` + +This will combine all of the layers required by your VNF layer into a single charm, in the builds/ directory. At this point, the charm can be delivered to a Network Operator for onboarding. + +### VNF Descriptor Package +Copy the combined charm into the `charm` directory of your [VNF package]: + +``` +├── charm +│   └── myvnf +├── cloud_init +│   └── myvnf_cloud_init.cfg +├── icons +│   └── myvnf_logo.png +└── myvnf_vnfd.yaml +``` + +## Contact + +Send an email to the OSM_TECH@list.etsi.org mailing list. + +[VNF package]: https://osm.etsi.org/wikipub/index.php/Creating_your_own_VNF_package_(Release_TWO) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions.yaml new file mode 100644 index 00000000..096b9d38 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions.yaml @@ -0,0 +1,231 @@ +## +# Copyright 2016 Canonical Ltd. +# All rights reserved. +# +# 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. +## + +"run": + "description": "Run an arbitrary command" + "params": + "command": + "description": "The command to execute." + "type": "string" + "default": "" + "required": + - "command" +"generate-ssh-key": + "description": "Generate a new SSH keypair for this unit. This will replace any\ + \ existing previously generated keypair." +"verify-ssh-credentials": + "description": "Verify that this unit can authenticate with server specified by\ + \ ssh-hostname and ssh-username." +"get-ssh-public-key": + "description": "Get the public SSH key for this unit." +"start": + "description": "Stop the service on the VNF." +"stop": + "description": "Stop the service on the VNF." +"restart": + "description": "Stop the service on the VNF." +"reboot": + "description": "Reboot the VNF virtual machine." +"upgrade": + "description": "Upgrade the software on the VNF." +"setup-juju": + "description": "Adds a local manual cloud, bootstraps the controller" +"add-machine": + "description": "Add one machine to the local cloud" + "params": + "machine": + "description": "IP address of machine" + "type": "string" + "default": "" +"add-machines": + "description": "Add machines to the local cloud" + "params": + "machine1": + "description": "IP address of machine1" + "type": "string" + "default": "" + "machine2": + "description": "IP address of machine2" + "type": "string" + "default": "" + "machine3": + "description": "IP address of machine3" + "type": "string" + "default": "" + "machine4": + "description": "IP address of machine4" + "type": "string" + "default": "" + "machine5": + "description": "IP address of machine5" + "type": "string" + "default": "" + "machine6": + "description": "IP address of machine6" + "type": "string" + "default": "" + "machine7": + "description": "IP address of machine7" + "type": "string" + "default": "" + "machine8": + "description": "IP address of machine8" + "type": "string" + "default": "" + "machine9": + "description": "IP address of machine9" + "type": "string" + "default": "" + "machine10": + "description": "IP address of machine10" + "type": "string" + "default": "" + "required": + - "machine1" + - "machine2" + - "machine3" + - "machine4" +"remove-machines": + "description": "Remove all machines" + "params": + "force": + "description": "Flag to force the removal" + "type": "boolean" + "default": !!bool "false" +"deploy-bundle": + "description": "Deploys the bundle in the machines" + "params": + "bundle": + "description": "Optional bundle in JSON/YAML string format" + "type": "string" + "default": "" +"undeploy-bundle": + "description": "Remove all applications of the bundle that was deployed" +"post-deploy": + "description": "Configuration after deployment (kubectl, juju privileges)" +"init-helm": + "description": "Initialize helm" +"install-openebs-kubectl": + "description": "Install OpenEBS with kubectl, required for PVC" +"install-openebs-chart": + "description": "Install OpenEBS helm chart, required for PVC" +"add-repo": + "description": "Add repo to helm" + "params": + "name": + "description": "Name of the repo" + "type": "string" + "default": "" + "url": + "description": "URL of the repo" + "type": "string" + "default": "" + "required": + - "name" + - "url" +"remove-repo": + "description": "Remove repo from helm" + "params": + "name": + "description": "Name of the repo" + "type": "string" + "default": "" + "required": + - "name" +"install-chart": + "description": "Install chart" + "params": + "chart": + "description": "Name of the chart" + "type": "string" + "default": "" + "name": + "description": "Name of the release" + "type": "string" + "default": "" + "namespace": + "description": "Namespace where the release will be set" + "type": "string" + "default": "" + "atomic": + "description": "Flag to run it as atomic" + "type": "boolean" + "default": !!bool "false" + "values": + "description": "Serialized values of a YAML file in a string" + "type": "string" + "default": "" + "valuesFile": + "description": "Values in a YAML file or a URL" + "type": "string" + "default": "" + "required": + - "chart" + - "name" +"upgrade-release": + "description": "Upgrade release" + "params": + "name": + "description": "Name of the release" + "type": "string" + "default": "" + "chart": + "description": "Name of the chart" + "type": "string" + "default": "" + "namespace": + "description": "Namespace where the release will be set" + "type": "string" + "default": "" + "atomic": + "description": "Flag to run it as atomic" + "type": "boolean" + "default": "" + "values": + "description": "Serialized values of a YAML file in a string" + "type": "string" + "default": "" + "valuesFile": + "description": "Values in a YAML file or a URL" + "type": "string" + "default": "" + "required": + - "name" + - "chart" +"rollback-release": + "description": "Rollback release" + "params": + "name": + "description": "Name of the release" + "type": "string" + "default": "" + "revision": + "description": "Revision of the release" + "type": "string" + "default": "0" + "required": + - "name" +"delete-release": + "description": "Delete release" + "params": + "name": + "description": "Name of the release" + "type": "string" + "default": "" + "required": + - "name" + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/add-machine b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/add-machine new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/add-machine @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/add-machines b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/add-machines new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/add-machines @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/add-repo b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/add-repo new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/add-repo @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/delete-release b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/delete-release new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/delete-release @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/deploy-bundle b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/deploy-bundle new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/deploy-bundle @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/generate-ssh-key b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/generate-ssh-key new file mode 100755 index 00000000..7e30af4c --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/generate-ssh-key @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/get-ssh-public-key b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/get-ssh-public-key new file mode 100755 index 00000000..7e30af4c --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/get-ssh-public-key @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/init-helm b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/init-helm new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/init-helm @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/install-chart b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/install-chart new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/install-chart @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/install-openebs-chart b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/install-openebs-chart new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/install-openebs-chart @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/install-openebs-kubectl b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/install-openebs-kubectl new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/install-openebs-kubectl @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/post-deploy b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/post-deploy new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/post-deploy @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/reboot b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/reboot new file mode 100755 index 00000000..9a2ba24b --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/reboot @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +import sys +sys.path.append('lib') +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/remove-machines b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/remove-machines new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/remove-machines @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/remove-repo b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/remove-repo new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/remove-repo @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/restart b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/restart new file mode 100755 index 00000000..9a2ba24b --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/restart @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +import sys +sys.path.append('lib') +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/rollback-release b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/rollback-release new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/rollback-release @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/run b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/run new file mode 100755 index 00000000..7e30af4c --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/run @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/setup-juju b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/setup-juju new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/setup-juju @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/start b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/start new file mode 100755 index 00000000..9a2ba24b --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/start @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +import sys +sys.path.append('lib') +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/stop b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/stop new file mode 100755 index 00000000..9a2ba24b --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/stop @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +import sys +sys.path.append('lib') +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/undeploy-bundle b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/undeploy-bundle new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/undeploy-bundle @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/upgrade b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/upgrade new file mode 100755 index 00000000..9a2ba24b --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/upgrade @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +import sys +sys.path.append('lib') +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/upgrade-release b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/upgrade-release new file mode 100755 index 00000000..e13c144d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/upgrade-release @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# Copyright 2017-18 Telefonica +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/verify-ssh-credentials b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/verify-ssh-credentials new file mode 100755 index 00000000..7e30af4c --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/actions/verify-ssh-credentials @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +## +# Copyright 2016 Canonical Ltd. +# All rights reserved. +# +# 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. +## +import sys +sys.path.append('lib') + +from charms.reactive import main, set_flag +from charmhelpers.core.hookenv import action_fail, action_name + +""" +`set_state` only works here because it's flushed to disk inside the `main()` +loop. remove_state will need to be called inside the action method. +""" +set_flag('actions.{}'.format(action_name())) + +try: + main() +except Exception as e: + action_fail(repr(e)) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/bin/charm-env b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/bin/charm-env new file mode 100755 index 00000000..aca7de3c --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/bin/charm-env @@ -0,0 +1,107 @@ +#!/bin/bash + +VERSION="1.0.0" + + +find_charm_dirs() { + # Hopefully, $JUJU_CHARM_DIR is set so which venv to use in unambiguous. + if [[ -n "$JUJU_CHARM_DIR" || -n "$CHARM_DIR" ]]; then + if [[ -z "$JUJU_CHARM_DIR" ]]; then + # accept $CHARM_DIR to be more forgiving + export JUJU_CHARM_DIR="$CHARM_DIR" + fi + if [[ -z "$CHARM_DIR" ]]; then + # set CHARM_DIR as well to help with backwards compatibility + export CHARM_DIR="$JUJU_CHARM_DIR" + fi + return + fi + # Try to guess the value for JUJU_CHARM_DIR by looking for a non-subordinate + # (because there's got to be at least one principle) charm directory; + # if there are several, pick the first by alpha order. + agents_dir="/var/lib/juju/agents" + if [[ -d "$agents_dir" ]]; then + desired_charm="$1" + found_charm_dir="" + if [[ -n "$desired_charm" ]]; then + for charm_dir in $(/bin/ls -d "$agents_dir"/unit-*/charm); do + charm_name="$(JUJU_CHARM_DIR="$charm_dir" charm-env python3 -c 'from charmhelpers.core.hookenv import charm_name; print(charm_name())')" + if [[ "$charm_name" == "$desired_charm" ]]; then + if [[ -n "$found_charm_dir" ]]; then + >&2 echo "Ambiguous possibilities for JUJU_CHARM_DIR matching '$desired_charm'; please run within a Juju hook context" + exit 1 + fi + found_charm_dir="$charm_dir" + fi + done + if [[ -z "$found_charm_dir" ]]; then + >&2 echo "Unable to determine JUJU_CHARM_DIR matching '$desired_charm'; please run within a Juju hook context" + exit 1 + fi + export JUJU_CHARM_DIR="$found_charm_dir" + export CHARM_DIR="$found_charm_dir" + return + fi + # shellcheck disable=SC2126 + non_subordinates="$(grep -L 'subordinate:.*true' "$agents_dir"/unit-*/charm/metadata.yaml | wc -l)" + if [[ "$non_subordinates" -gt 1 ]]; then + >&2 echo 'Ambiguous possibilities for JUJU_CHARM_DIR; please use --charm or run within a Juju hook context' + exit 1 + elif [[ "$non_subordinates" -eq 1 ]]; then + for charm_dir in $(/bin/ls -d "$agents_dir"/unit-*/charm); do + if grep -q 'subordinate:.*true' "$charm_dir/metadata.yaml"; then + continue + fi + export JUJU_CHARM_DIR="$charm_dir" + export CHARM_DIR="$charm_dir" + return + done + fi + fi + >&2 echo 'Unable to determine JUJU_CHARM_DIR; please run within a Juju hook context' + exit 1 +} + +try_activate_venv() { + if [[ -d "$JUJU_CHARM_DIR/../.venv" ]]; then + . "$JUJU_CHARM_DIR/../.venv/bin/activate" + fi +} + +find_wrapped() { + PATH="${PATH/\/usr\/local\/sbin:}" which "$(basename "$0")" +} + + +if [[ "$1" == "--version" || "$1" == "-v" ]]; then + echo "$VERSION" + exit 0 +fi + + +# allow --charm option to hint which JUJU_CHARM_DIR to choose when ambiguous +# NB: --charm option must come first +# NB: option must be processed outside find_charm_dirs to modify $@ +charm_name="" +if [[ "$1" == "--charm" ]]; then + charm_name="$2" + shift; shift +fi + +find_charm_dirs "$charm_name" +try_activate_venv +export PYTHONPATH="$JUJU_CHARM_DIR/lib:$PYTHONPATH" + +if [[ "$(basename "$0")" == "charm-env" ]]; then + # being used as a shebang + exec "$@" +elif [[ "$0" == "$BASH_SOURCE" ]]; then + # being invoked as a symlink wrapping something to find in the venv + exec "$(find_wrapped)" "$@" +elif [[ "$(basename "$BASH_SOURCE")" == "charm-env" ]]; then + # being sourced directly; do nothing + /bin/true +else + # being sourced for wrapped bash helpers + . "$(find_wrapped)" +fi diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/bin/layer_option b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/bin/layer_option new file mode 100755 index 00000000..3253ef8a --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/bin/layer_option @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import sys +import argparse +from charms import layer + + +parser = argparse.ArgumentParser(description='Access layer options.') +parser.add_argument('section', + help='the section, or layer, the option is from') +parser.add_argument('option', + help='the option to access') + +args = parser.parse_args() +value = layer.options.get(args.section, args.option) +if isinstance(value, bool): + sys.exit(0 if value else 1) +elif isinstance(value, list): + for val in value: + print(val) +else: + print(value) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/config.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/config.yaml new file mode 100644 index 00000000..737c3788 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/config.yaml @@ -0,0 +1,42 @@ +"options": + "ssh-hostname": + "type": "string" + "default": "" + "description": "The hostname or IP address of the machine to" + "ssh-username": + "type": "string" + "default": "" + "description": "The username to login as." + "ssh-password": + "type": "string" + "default": "" + "description": "The password used to authenticate." + "ssh-private-key": + "type": "string" + "default": "" + "description": "DEPRECATED. The private ssh key to be used to authenticate." + "ssh-public-key": + "type": "string" + "default": "" + "description": "The public key of this unit." + "ssh-key-type": + "type": "string" + "default": "rsa" + "description": "The type of encryption to use for the SSH key." + "ssh-key-bits": + "type": "int" + "default": !!int "4096" + "description": "The number of bits to use for the SSH key." + "string-option": + "type": "string" + "default": "Default Value" + "description": "A short description of the configuration option" + "boolean-option": + "type": "boolean" + "default": !!bool "false" + "description": "A short description of the configuration option" + "int-option": + "type": "int" + "default": !!int "9001" + "description": "A short description of the configuration option" + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/copyright b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/copyright new file mode 100644 index 00000000..d4fdd182 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/copyright @@ -0,0 +1,16 @@ +Format: http://dep.debian.net/deps/dep5/ + +Files: * +Copyright: Copyright 2015-2017, Canonical Ltd., All Rights Reserved. +License: Apache License 2.0 + 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. diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/copyright.layer-options b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/copyright.layer-options new file mode 100644 index 00000000..d4fdd182 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/copyright.layer-options @@ -0,0 +1,16 @@ +Format: http://dep.debian.net/deps/dep5/ + +Files: * +Copyright: Copyright 2015-2017, Canonical Ltd., All Rights Reserved. +License: Apache License 2.0 + 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. diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/elastic-data.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/elastic-data.yaml new file mode 100644 index 00000000..65425894 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/elastic-data.yaml @@ -0,0 +1,27 @@ +clusterName: "srvfd-elk" +nodeGroup: "data" +masterService: "srvfd-elk-mst" +service: + type: "LoadBalancer" +roles: + master: "false" + ingest: "true" + data: "true" +replicas: 3 +image: "docker.elastic.co/elasticsearch/elasticsearch" +imageTag: "6.8.3" +esJavaOpts: "-Xmx1g -Xms1g" +resources: + requests: + cpu: "2" + memory: "4Gi" + limits: + cpu: "2" + memory: "4Gi" +volumeClaimTemplate: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 40Gi +antiAffinity: "hard" + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/elastic-kibana.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/elastic-kibana.yaml new file mode 100644 index 00000000..7b649be0 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/elastic-kibana.yaml @@ -0,0 +1,5 @@ +elasticsearchHosts: "http://srvfd-elk-mst:9200" +imageTag: "6.8.3" +service: + type: "LoadBalancer" + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/elastic-master.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/elastic-master.yaml new file mode 100644 index 00000000..a1b5def0 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/elastic-master.yaml @@ -0,0 +1,23 @@ +clusterName: "srvfd-elk" +nodeGroup: "mst" +masterService: "srvfd-elk-mst" +service: + type: "LoadBalancer" +roles: + master: "true" + ingest: "false" + data: "false" +replicas: 3 +minimumMasterNodes: 2 +image: "docker.elastic.co/elasticsearch/elasticsearch" +imageTag: "6.8.3" +esJavaOpts: "-Xmx1g -Xms1g" +resources: + requests: + cpu: "1" + memory: "2Gi" + limits: + cpu: "2" + memory: "2Gi" +antiAffinity: "hard" + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/kafka-bitnami.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/kafka-bitnami.yaml new file mode 100644 index 00000000..30c1ca0b --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/kafka-bitnami.yaml @@ -0,0 +1,18 @@ +clusterDomain: "cluster.local" +image: + tag: "1.1.1-debian-9-r307" +replicaCount: 4 +service: + type: "LoadBalancer" +persistence: + size: "20Gi" +resources: + limits: + cpu: 2 + memory: "4Gi" + requests: + memory: "4Gi" + cpu: 2 +zookeeper: + enabled: true + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/nifi-cetic.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/nifi-cetic.yaml new file mode 100644 index 00000000..571bcc7c --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/nifi-cetic.yaml @@ -0,0 +1,8 @@ +resources: + requests: + cpu: "2" + memory: "4Gi" + limits: + cpu: "2" + memory: "4Gi" + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/spark-bitnami.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/spark-bitnami.yaml new file mode 100644 index 00000000..8b02b296 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/helm/spark-bitnami.yaml @@ -0,0 +1,49 @@ +image: + tag: 2.4.4-debian-9-r27 +master: + debug: false + daemonMemoryLimit: 4g + resources: + limits: + cpu: 4 + memory: 8Gi + requests: + memory: 8Gi + cpu: 4 +worker: + replicaCount: 3 + memoryLimit: 8g + daemonMemoryLimit: 4g + coreLimit: 4 + debug: true + autoscaling: + enabled: false + CpuTargetPercentage: 50 + replicasMax: 5 + debug: false + resources: + limits: + cpu: 4 + memory: 8Gi + requests: + memory: 8Gi + cpu: 4 +security: + rpc: + authenticationEnabled: no + encryptionEnabled: no + storageEncryptionEnabled: no + ssl: + enabled: no + needClientAuth: no + protocol: TLSv1.2 +service: + type: LoadBalancer + clusterPort: 7077 + webPort: 80 +ingress: + enabled: false + hosts: + - name: spark.local + path: / + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/collect-metrics b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/collect-metrics new file mode 100755 index 00000000..ecd7e623 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/collect-metrics @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +"""Handle the collect-metrics hook via proxy. + +The normal metrics layer will only execute metrics collection against the local +machine. This hook implements the same approach, but runs the collection code +against the configured ssh proxy. + +Because the metrics hook runs in a restricted context, it can't be run as a +normal reactive event, nor can it access things like config. +""" + +import os +import shlex +from subprocess import check_call, CalledProcessError +import sys +import yaml + +# Load modules from $CHARM_DIR/lib +sys.path.append('lib') +import charms.sshproxy + + +def build_command(doc): + """Build the commands to report metrics. + + Build a list of `add-metric` commands to report the current metrics + back to the Juju controller. + """ + values = {} + metrics = doc.get("metrics", {}) + for metric, mdoc in metrics.items(): + cmd = mdoc.get("command") + if cmd: + try: + value, err = charms.sshproxy._run( + # The command may contain quotes that need to be preserved, + # i.e., `awk '{print $1}' /proc/uptime` + shlex.split(cmd, posix=False) + ) + except Exception as e: + # Ignore all errors + with open("metrics.log", "a") as f: + f.write("{}".format(e)) + continue + + if isinstance(value, bytes): + value = value.decode('utf-8') + + value = value.strip() + if value: + values[metric] = value + + if not values: + return None + command = ["add-metric"] + for metric, value in values.items(): + command.append("%s=%s" % (metric, value)) + return command + + +if __name__ == '__main__': + charm_dir = os.path.dirname(os.path.abspath(os.path.join(__file__, ".."))) + metrics_yaml = os.path.join(charm_dir, "metrics.yaml") + with open(metrics_yaml) as f: + doc = yaml.load(f) + command = build_command(doc) + if command: + check_call(command) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/config-changed b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/config-changed new file mode 100755 index 00000000..9858c6be --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/config-changed @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +# Load modules from $JUJU_CHARM_DIR/lib +import sys +sys.path.append('lib') + +from charms.layer import basic # noqa +basic.bootstrap_charm_deps() + +from charmhelpers.core import hookenv # noqa +hookenv.atstart(basic.init_config_states) +hookenv.atexit(basic.clear_config_states) + + +# This will load and run the appropriate @hook and other decorated +# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, +# and $JUJU_CHARM_DIR/hooks/relations. +# +# See https://jujucharms.com/docs/stable/authors-charm-building +# for more information on this pattern. +from charms.reactive import main # noqa +main() diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/hook.template b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/hook.template new file mode 100644 index 00000000..9858c6be --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/hook.template @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +# Load modules from $JUJU_CHARM_DIR/lib +import sys +sys.path.append('lib') + +from charms.layer import basic # noqa +basic.bootstrap_charm_deps() + +from charmhelpers.core import hookenv # noqa +hookenv.atstart(basic.init_config_states) +hookenv.atexit(basic.clear_config_states) + + +# This will load and run the appropriate @hook and other decorated +# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, +# and $JUJU_CHARM_DIR/hooks/relations. +# +# See https://jujucharms.com/docs/stable/authors-charm-building +# for more information on this pattern. +from charms.reactive import main # noqa +main() diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/install b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/install new file mode 100755 index 00000000..9858c6be --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/install @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +# Load modules from $JUJU_CHARM_DIR/lib +import sys +sys.path.append('lib') + +from charms.layer import basic # noqa +basic.bootstrap_charm_deps() + +from charmhelpers.core import hookenv # noqa +hookenv.atstart(basic.init_config_states) +hookenv.atexit(basic.clear_config_states) + + +# This will load and run the appropriate @hook and other decorated +# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, +# and $JUJU_CHARM_DIR/hooks/relations. +# +# See https://jujucharms.com/docs/stable/authors-charm-building +# for more information on this pattern. +from charms.reactive import main # noqa +main() diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/leader-elected b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/leader-elected new file mode 100755 index 00000000..9858c6be --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/leader-elected @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +# Load modules from $JUJU_CHARM_DIR/lib +import sys +sys.path.append('lib') + +from charms.layer import basic # noqa +basic.bootstrap_charm_deps() + +from charmhelpers.core import hookenv # noqa +hookenv.atstart(basic.init_config_states) +hookenv.atexit(basic.clear_config_states) + + +# This will load and run the appropriate @hook and other decorated +# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, +# and $JUJU_CHARM_DIR/hooks/relations. +# +# See https://jujucharms.com/docs/stable/authors-charm-building +# for more information on this pattern. +from charms.reactive import main # noqa +main() diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/leader-settings-changed b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/leader-settings-changed new file mode 100755 index 00000000..9858c6be --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/leader-settings-changed @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +# Load modules from $JUJU_CHARM_DIR/lib +import sys +sys.path.append('lib') + +from charms.layer import basic # noqa +basic.bootstrap_charm_deps() + +from charmhelpers.core import hookenv # noqa +hookenv.atstart(basic.init_config_states) +hookenv.atexit(basic.clear_config_states) + + +# This will load and run the appropriate @hook and other decorated +# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, +# and $JUJU_CHARM_DIR/hooks/relations. +# +# See https://jujucharms.com/docs/stable/authors-charm-building +# for more information on this pattern. +from charms.reactive import main # noqa +main() diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/post-series-upgrade b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/post-series-upgrade new file mode 100755 index 00000000..9858c6be --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/post-series-upgrade @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +# Load modules from $JUJU_CHARM_DIR/lib +import sys +sys.path.append('lib') + +from charms.layer import basic # noqa +basic.bootstrap_charm_deps() + +from charmhelpers.core import hookenv # noqa +hookenv.atstart(basic.init_config_states) +hookenv.atexit(basic.clear_config_states) + + +# This will load and run the appropriate @hook and other decorated +# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, +# and $JUJU_CHARM_DIR/hooks/relations. +# +# See https://jujucharms.com/docs/stable/authors-charm-building +# for more information on this pattern. +from charms.reactive import main # noqa +main() diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/pre-series-upgrade b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/pre-series-upgrade new file mode 100755 index 00000000..9858c6be --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/pre-series-upgrade @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +# Load modules from $JUJU_CHARM_DIR/lib +import sys +sys.path.append('lib') + +from charms.layer import basic # noqa +basic.bootstrap_charm_deps() + +from charmhelpers.core import hookenv # noqa +hookenv.atstart(basic.init_config_states) +hookenv.atexit(basic.clear_config_states) + + +# This will load and run the appropriate @hook and other decorated +# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, +# and $JUJU_CHARM_DIR/hooks/relations. +# +# See https://jujucharms.com/docs/stable/authors-charm-building +# for more information on this pattern. +from charms.reactive import main # noqa +main() diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/start b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/start new file mode 100755 index 00000000..9858c6be --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/start @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +# Load modules from $JUJU_CHARM_DIR/lib +import sys +sys.path.append('lib') + +from charms.layer import basic # noqa +basic.bootstrap_charm_deps() + +from charmhelpers.core import hookenv # noqa +hookenv.atstart(basic.init_config_states) +hookenv.atexit(basic.clear_config_states) + + +# This will load and run the appropriate @hook and other decorated +# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, +# and $JUJU_CHARM_DIR/hooks/relations. +# +# See https://jujucharms.com/docs/stable/authors-charm-building +# for more information on this pattern. +from charms.reactive import main # noqa +main() diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/stop b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/stop new file mode 100755 index 00000000..9858c6be --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/stop @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +# Load modules from $JUJU_CHARM_DIR/lib +import sys +sys.path.append('lib') + +from charms.layer import basic # noqa +basic.bootstrap_charm_deps() + +from charmhelpers.core import hookenv # noqa +hookenv.atstart(basic.init_config_states) +hookenv.atexit(basic.clear_config_states) + + +# This will load and run the appropriate @hook and other decorated +# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, +# and $JUJU_CHARM_DIR/hooks/relations. +# +# See https://jujucharms.com/docs/stable/authors-charm-building +# for more information on this pattern. +from charms.reactive import main # noqa +main() diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/update-status b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/update-status new file mode 100755 index 00000000..9858c6be --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/update-status @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +# Load modules from $JUJU_CHARM_DIR/lib +import sys +sys.path.append('lib') + +from charms.layer import basic # noqa +basic.bootstrap_charm_deps() + +from charmhelpers.core import hookenv # noqa +hookenv.atstart(basic.init_config_states) +hookenv.atexit(basic.clear_config_states) + + +# This will load and run the appropriate @hook and other decorated +# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, +# and $JUJU_CHARM_DIR/hooks/relations. +# +# See https://jujucharms.com/docs/stable/authors-charm-building +# for more information on this pattern. +from charms.reactive import main # noqa +main() diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/upgrade-charm b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/upgrade-charm new file mode 100755 index 00000000..9858c6be --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/hooks/upgrade-charm @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +# Load modules from $JUJU_CHARM_DIR/lib +import sys +sys.path.append('lib') + +from charms.layer import basic # noqa +basic.bootstrap_charm_deps() + +from charmhelpers.core import hookenv # noqa +hookenv.atstart(basic.init_config_states) +hookenv.atexit(basic.clear_config_states) + + +# This will load and run the appropriate @hook and other decorated +# handlers from $JUJU_CHARM_DIR/reactive, $JUJU_CHARM_DIR/hooks/reactive, +# and $JUJU_CHARM_DIR/hooks/relations. +# +# See https://jujucharms.com/docs/stable/authors-charm-building +# for more information on this pattern. +from charms.reactive import main # noqa +main() diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/icon.svg b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/icon.svg new file mode 100644 index 00000000..96a5d0c0 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/icon.svg @@ -0,0 +1,279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/layer.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/layer.yaml new file mode 100644 index 00000000..5d43c750 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/layer.yaml @@ -0,0 +1,16 @@ +"includes": +- "layer:options" +- "layer:basic" +- "layer:sshproxy" +- "layer:vnfproxy" +"exclude": [".travis.yml", "tests", "tox.ini", "test-requirements.txt"] +"options": + "basic": + "use_venv": !!bool "false" + "packages": [] + "python_packages": [] + "include_system_packages": !!bool "false" + "sshproxy": {} + "vnfproxy": {} + "tid-jujuk8s": {} +"is": "tid-jujuk8s" diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/layer/__init__.py b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/layer/__init__.py new file mode 100644 index 00000000..a8e0c640 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/layer/__init__.py @@ -0,0 +1,60 @@ +import sys +from importlib import import_module +from pathlib import Path + + +def import_layer_libs(): + """ + Ensure that all layer libraries are imported. + + This makes it possible to do the following: + + from charms import layer + + layer.foo.do_foo_thing() + + Note: This function must be called after bootstrap. + """ + for module_file in Path('lib/charms/layer').glob('*'): + module_name = module_file.stem + if module_name in ('__init__', 'basic', 'execd') or not ( + module_file.suffix == '.py' or module_file.is_dir() + ): + continue + import_module('charms.layer.{}'.format(module_name)) + + +# Terrible hack to support the old terrible interface. +# Try to get people to call layer.options.get() instead so +# that we can remove this garbage. +# Cribbed from https://stackoverfLow.com/a/48100440/4941864 +class OptionsBackwardsCompatibilityHack(sys.modules[__name__].__class__): + def __call__(self, section=None, layer_file=None): + if layer_file is None: + return self.get(section=section) + else: + return self.get(section=section, + layer_file=Path(layer_file)) + + +def patch_options_interface(): + from charms.layer import options + if sys.version_info.minor >= 5: + options.__class__ = OptionsBackwardsCompatibilityHack + else: + # Py 3.4 doesn't support changing the __class__, so we have to do it + # another way. The last line is needed because we already have a + # reference that doesn't get updated with sys.modules. + name = options.__name__ + hack = OptionsBackwardsCompatibilityHack(name) + hack.get = options.get + sys.modules[name] = hack + sys.modules[__name__].options = hack + + +try: + patch_options_interface() +except ImportError: + # This may fail if pyyaml hasn't been installed yet. But in that + # case, the bootstrap logic will try it again once it has. + pass diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/layer/basic.py b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/layer/basic.py new file mode 100644 index 00000000..39319591 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/layer/basic.py @@ -0,0 +1,286 @@ +import os +import sys +import shutil +from glob import glob +from subprocess import check_call, check_output, CalledProcessError +from time import sleep + +from charms import layer +from charms.layer.execd import execd_preinstall + + +def lsb_release(): + """Return /etc/lsb-release in a dict""" + d = {} + with open('/etc/lsb-release', 'r') as lsb: + for l in lsb: + k, v = l.split('=') + d[k.strip()] = v.strip() + return d + + +def bootstrap_charm_deps(): + """ + Set up the base charm dependencies so that the reactive system can run. + """ + # execd must happen first, before any attempt to install packages or + # access the network, because sites use this hook to do bespoke + # configuration and install secrets so the rest of this bootstrap + # and the charm itself can actually succeed. This call does nothing + # unless the operator has created and populated $JUJU_CHARM_DIR/exec.d. + execd_preinstall() + # ensure that $JUJU_CHARM_DIR/bin is on the path, for helper scripts + charm_dir = os.environ['JUJU_CHARM_DIR'] + os.environ['PATH'] += ':%s' % os.path.join(charm_dir, 'bin') + venv = os.path.abspath('../.venv') + vbin = os.path.join(venv, 'bin') + vpip = os.path.join(vbin, 'pip') + vpy = os.path.join(vbin, 'python') + hook_name = os.path.basename(sys.argv[0]) + is_bootstrapped = os.path.exists('wheelhouse/.bootstrapped') + is_charm_upgrade = hook_name == 'upgrade-charm' + is_series_upgrade = hook_name == 'post-series-upgrade' + post_upgrade = os.path.exists('wheelhouse/.upgrade') + is_upgrade = not post_upgrade and (is_charm_upgrade or is_series_upgrade) + if is_bootstrapped and not is_upgrade: + # older subordinates might have downgraded charm-env, so we should + # restore it if necessary + install_or_update_charm_env() + activate_venv() + # the .upgrade file prevents us from getting stuck in a loop + # when re-execing to activate the venv; at this point, we've + # activated the venv, so it's safe to clear it + if post_upgrade: + os.unlink('wheelhouse/.upgrade') + return + if is_series_upgrade and os.path.exists(venv): + # series upgrade should do a full clear of the venv, rather than just + # updating it, to bring in updates to Python itself + shutil.rmtree(venv) + if is_upgrade: + if os.path.exists('wheelhouse/.bootstrapped'): + os.unlink('wheelhouse/.bootstrapped') + open('wheelhouse/.upgrade', 'w').close() + # bootstrap wheelhouse + if os.path.exists('wheelhouse'): + with open('/root/.pydistutils.cfg', 'w') as fp: + # make sure that easy_install also only uses the wheelhouse + # (see https://github.com/pypa/pip/issues/410) + fp.writelines([ + "[easy_install]\n", + "allow_hosts = ''\n", + "find_links = file://{}/wheelhouse/\n".format(charm_dir), + ]) + apt_install([ + 'python3-pip', + 'python3-setuptools', + 'python3-yaml', + 'python3-dev', + 'python3-wheel', + 'build-essential', + ]) + from charms.layer import options + cfg = options.get('basic') + # include packages defined in layer.yaml + apt_install(cfg.get('packages', [])) + # if we're using a venv, set it up + if cfg.get('use_venv'): + if not os.path.exists(venv): + series = lsb_release()['DISTRIB_CODENAME'] + if series in ('precise', 'trusty'): + apt_install(['python-virtualenv']) + else: + apt_install(['virtualenv']) + cmd = ['virtualenv', '-ppython3', '--never-download', venv] + if cfg.get('include_system_packages'): + cmd.append('--system-site-packages') + check_call(cmd) + os.environ['PATH'] = ':'.join([vbin, os.environ['PATH']]) + pip = vpip + else: + pip = 'pip3' + # save a copy of system pip to prevent `pip3 install -U pip` + # from changing it + if os.path.exists('/usr/bin/pip'): + shutil.copy2('/usr/bin/pip', '/usr/bin/pip.save') + # need newer pip, to fix spurious Double Requirement error: + # https://github.com/pypa/pip/issues/56 + check_call([pip, 'install', '-U', '--no-index', '-f', 'wheelhouse', + 'pip']) + # per https://github.com/juju-solutions/layer-basic/issues/110 + # this replaces the setuptools that was copied over from the system on + # venv create with latest setuptools and adds setuptools_scm + check_call([pip, 'install', '-U', '--no-index', '-f', 'wheelhouse', + 'setuptools', 'setuptools-scm']) + # install the rest of the wheelhouse deps + check_call([pip, 'install', '-U', '--ignore-installed', '--no-index', + '-f', 'wheelhouse'] + glob('wheelhouse/*')) + # re-enable installation from pypi + os.remove('/root/.pydistutils.cfg') + # install python packages from layer options + if cfg.get('python_packages'): + check_call([pip, 'install', '-U'] + cfg.get('python_packages')) + if not cfg.get('use_venv'): + # restore system pip to prevent `pip3 install -U pip` + # from changing it + if os.path.exists('/usr/bin/pip.save'): + shutil.copy2('/usr/bin/pip.save', '/usr/bin/pip') + os.remove('/usr/bin/pip.save') + # setup wrappers to ensure envs are used for scripts + install_or_update_charm_env() + for wrapper in ('charms.reactive', 'charms.reactive.sh', + 'chlp', 'layer_option'): + src = os.path.join('/usr/local/sbin', 'charm-env') + dst = os.path.join('/usr/local/sbin', wrapper) + if not os.path.exists(dst): + os.symlink(src, dst) + if cfg.get('use_venv'): + shutil.copy2('bin/layer_option', vbin) + else: + shutil.copy2('bin/layer_option', '/usr/local/bin/') + # re-link the charm copy to the wrapper in case charms + # call bin/layer_option directly (as was the old pattern) + os.remove('bin/layer_option') + os.symlink('/usr/local/sbin/layer_option', 'bin/layer_option') + # flag us as having already bootstrapped so we don't do it again + open('wheelhouse/.bootstrapped', 'w').close() + # Ensure that the newly bootstrapped libs are available. + # Note: this only seems to be an issue with namespace packages. + # Non-namespace-package libs (e.g., charmhelpers) are available + # without having to reload the interpreter. :/ + reload_interpreter(vpy if cfg.get('use_venv') else sys.argv[0]) + + +def install_or_update_charm_env(): + # On Trusty python3-pkg-resources is not installed + try: + from pkg_resources import parse_version + except ImportError: + apt_install(['python3-pkg-resources']) + from pkg_resources import parse_version + + try: + installed_version = parse_version( + check_output(['/usr/local/sbin/charm-env', + '--version']).decode('utf8')) + except (CalledProcessError, FileNotFoundError): + installed_version = parse_version('0.0.0') + try: + bundled_version = parse_version( + check_output(['bin/charm-env', + '--version']).decode('utf8')) + except (CalledProcessError, FileNotFoundError): + bundled_version = parse_version('0.0.0') + if installed_version < bundled_version: + shutil.copy2('bin/charm-env', '/usr/local/sbin/') + + +def activate_venv(): + """ + Activate the venv if enabled in ``layer.yaml``. + + This is handled automatically for normal hooks, but actions might + need to invoke this manually, using something like: + + # Load modules from $JUJU_CHARM_DIR/lib + import sys + sys.path.append('lib') + + from charms.layer.basic import activate_venv + activate_venv() + + This will ensure that modules installed in the charm's + virtual environment are available to the action. + """ + from charms.layer import options + venv = os.path.abspath('../.venv') + vbin = os.path.join(venv, 'bin') + vpy = os.path.join(vbin, 'python') + use_venv = options.get('basic', 'use_venv') + if use_venv and '.venv' not in sys.executable: + # activate the venv + os.environ['PATH'] = ':'.join([vbin, os.environ['PATH']]) + reload_interpreter(vpy) + layer.patch_options_interface() + layer.import_layer_libs() + + +def reload_interpreter(python): + """ + Reload the python interpreter to ensure that all deps are available. + + Newly installed modules in namespace packages sometimes seemt to + not be picked up by Python 3. + """ + os.execve(python, [python] + list(sys.argv), os.environ) + + +def apt_install(packages): + """ + Install apt packages. + + This ensures a consistent set of options that are often missed but + should really be set. + """ + if isinstance(packages, (str, bytes)): + packages = [packages] + + env = os.environ.copy() + + if 'DEBIAN_FRONTEND' not in env: + env['DEBIAN_FRONTEND'] = 'noninteractive' + + cmd = ['apt-get', + '--option=Dpkg::Options::=--force-confold', + '--assume-yes', + 'install'] + for attempt in range(3): + try: + check_call(cmd + packages, env=env) + except CalledProcessError: + if attempt == 2: # third attempt + raise + try: + # sometimes apt-get update needs to be run + check_call(['apt-get', 'update']) + except CalledProcessError: + # sometimes it's a dpkg lock issue + pass + sleep(5) + else: + break + + +def init_config_states(): + import yaml + from charmhelpers.core import hookenv + from charms.reactive import set_state + from charms.reactive import toggle_state + config = hookenv.config() + config_defaults = {} + config_defs = {} + config_yaml = os.path.join(hookenv.charm_dir(), 'config.yaml') + if os.path.exists(config_yaml): + with open(config_yaml) as fp: + config_defs = yaml.safe_load(fp).get('options', {}) + config_defaults = {key: value.get('default') + for key, value in config_defs.items()} + for opt in config_defs.keys(): + if config.changed(opt): + set_state('config.changed') + set_state('config.changed.{}'.format(opt)) + toggle_state('config.set.{}'.format(opt), config.get(opt)) + toggle_state('config.default.{}'.format(opt), + config.get(opt) == config_defaults[opt]) + + +def clear_config_states(): + from charmhelpers.core import hookenv, unitdata + from charms.reactive import remove_state + config = hookenv.config() + remove_state('config.changed') + for opt in config.keys(): + remove_state('config.changed.{}'.format(opt)) + remove_state('config.set.{}'.format(opt)) + remove_state('config.default.{}'.format(opt)) + unitdata.kv().flush() diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/layer/execd.py b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/layer/execd.py new file mode 100644 index 00000000..438d9a1b --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/lib/charms/layer/execd.py @@ -0,0 +1,114 @@ +# Copyright 2014-2016 Canonical Limited. +# +# This file is part of layer-basic, the reactive base layer for Juju. +# +# charm-helpers is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 as +# published by the Free Software Foundation. +# +# charm-helpers is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with charm-helpers. If not, see . + +# This module may only import from the Python standard library. +import os +import sys +import subprocess +import time + +''' +execd/preinstall + +Read the layer-basic docs for more info on how to use this feature. +https://charmsreactive.readthedocs.io/en/latest/layer-basic.html#exec-d-support +''' + + +def default_execd_dir(): + return os.path.join(os.environ['JUJU_CHARM_DIR'], 'exec.d') + + +def execd_module_paths(execd_dir=None): + """Generate a list of full paths to modules within execd_dir.""" + if not execd_dir: + execd_dir = default_execd_dir() + + if not os.path.exists(execd_dir): + return + + for subpath in os.listdir(execd_dir): + module = os.path.join(execd_dir, subpath) + if os.path.isdir(module): + yield module + + +def execd_submodule_paths(command, execd_dir=None): + """Generate a list of full paths to the specified command within exec_dir. + """ + for module_path in execd_module_paths(execd_dir): + path = os.path.join(module_path, command) + if os.access(path, os.X_OK) and os.path.isfile(path): + yield path + + +def execd_sentinel_path(submodule_path): + module_path = os.path.dirname(submodule_path) + execd_path = os.path.dirname(module_path) + module_name = os.path.basename(module_path) + submodule_name = os.path.basename(submodule_path) + return os.path.join(execd_path, + '.{}_{}.done'.format(module_name, submodule_name)) + + +def execd_run(command, execd_dir=None, stop_on_error=True, stderr=None): + """Run command for each module within execd_dir which defines it.""" + if stderr is None: + stderr = sys.stdout + for submodule_path in execd_submodule_paths(command, execd_dir): + # Only run each execd once. We cannot simply run them in the + # install hook, as potentially storage hooks are run before that. + # We cannot rely on them being idempotent. + sentinel = execd_sentinel_path(submodule_path) + if os.path.exists(sentinel): + continue + + try: + subprocess.check_call([submodule_path], stderr=stderr, + universal_newlines=True) + with open(sentinel, 'w') as f: + f.write('{} ran successfully {}\n'.format(submodule_path, + time.ctime())) + f.write('Removing this file will cause it to be run again\n') + except subprocess.CalledProcessError as e: + # Logs get the details. We can't use juju-log, as the + # output may be substantial and exceed command line + # length limits. + print("ERROR ({}) running {}".format(e.returncode, e.cmd), + file=stderr) + print("STDOUT< 0: + raise CalledProcessError(returncode=retcode, + cmd=cmd, + output=stderr.decode("utf-8").strip()) + return (stdout.decode('utf-8').strip(), stderr.decode('utf-8').strip()) + + +def _run(cmd, env=None): + """Run a command remotely via SSH. + + Note: The previous behavior was to run the command locally if SSH wasn't + configured, but that can lead to cases where execution succeeds when you'd + expect it not to. + """ + if isinstance(cmd, str): + cmd = shlex.split(cmd) + + if type(cmd) is not list: + cmd = [cmd] + + cfg = get_config() + + if cfg: + if all(k in cfg for k in ['ssh-hostname', 'ssh-username', + 'ssh-password', 'ssh-private-key']): + host = get_host_ip() + user = cfg['ssh-username'] + passwd = cfg['ssh-password'] + key = cfg['ssh-private-key'] # DEPRECATED + + if host and user: + return ssh(cmd, host, user, passwd, key) + + raise Exception("Invalid SSH credentials.") + + +def get_ssh_client(host, user, password=None, key=None): + """Return a connected Paramiko ssh object.""" + client = paramiko.SSHClient() + client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + + pkey = None + + # Check for the DEPRECATED private-key + if key: + f = io.StringIO(key) + pkey = paramiko.RSAKey.from_private_key(f) + else: + # Otherwise, check for the auto-generated private key + if os.path.exists('/root/.ssh/id_juju_sshproxy'): + with open('/root/.ssh/id_juju_sshproxy', 'r') as f: + pkey = paramiko.RSAKey.from_private_key(f) + + ########################################################################### + # There is a bug in some versions of OpenSSH 4.3 (CentOS/RHEL 5) where # + # the server may not send the SSH_MSG_USERAUTH_BANNER message except when # + # responding to an auth_none request. For example, paramiko will attempt # + # to use password authentication when a password is set, but the server # + # could deny that, instead requesting keyboard-interactive. The hack to # + # workaround this is to attempt a reconnect, which will receive the right # + # banner, and authentication can proceed. See the following for more info # + # https://github.com/paramiko/paramiko/issues/432 # + # https://github.com/paramiko/paramiko/pull/438 # + ########################################################################### + + try: + client.connect(host, port=22, username=user, + password=password, pkey=pkey) + except paramiko.ssh_exception.SSHException as e: + if 'Error reading SSH protocol banner' == str(e): + # Once more, with feeling + client.connect(host, port=22, username=user, + password=password, pkey=pkey) + else: + # Reraise the original exception + raise e + + return client + + +def sftp(local_file, remote_file, host, user, password=None, key=None): + """Copy a local file to a remote host.""" + client = get_ssh_client(host, user, password, key) + + # Create an sftp connection from the underlying transport + sftp = paramiko.SFTPClient.from_transport(client.get_transport()) + sftp.put(local_file, remote_file) + client.close() + + +def ssh(cmd, host, user, password=None, key=None): + """Run an arbitrary command over SSH.""" + client = get_ssh_client(host, user, password, key) + + cmds = ' '.join(cmd) + stdin, stdout, stderr = client.exec_command(cmds, get_pty=True) + retcode = stdout.channel.recv_exit_status() + client.close() # @TODO re-use connections + if retcode > 0: + output = stderr.read().strip() + raise CalledProcessError(returncode=retcode, cmd=cmd, + output=output) + return ( + stdout.read().decode('utf-8').strip(), + stderr.read().decode('utf-8').strip() + ) diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/metadata.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/metadata.yaml new file mode 100644 index 00000000..0cf5f923 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/metadata.yaml @@ -0,0 +1,25 @@ +"name": "tid-jujuk8s" +"summary": "A charm for k8s_jujucontroller_vnf to deploy a K8s cluster" +"maintainers": +- "garciadeblas " +- "garomero " +"description": | + A charm to manage k8s_jujucontroller_vnf in order to deploy a k8s cluster. + It assumes that juju is already installed via cloud-init, with a manual cloud + and a bootstrapped controller. + It has an action "create-cluster" that receives the IP addresses of the 4 machines + belonging to the cluster and does the following: + - Copy ssh key of the juju controller to the machines + - Add the machines to juju + - Deploys the k8s bundle in the machines. +"tags": + # Replace "misc" with one or more whitelisted tags from this list: + # https://jujucharms.com/docs/stable/authors-charm-metadata +- "misc" +- "osm" +- "vnf" +"series": +- "bionic" +- "xenial" +- "trusty" +"subordinate": !!bool "false" diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/__init__.py b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/sshproxy.py b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/sshproxy.py new file mode 100644 index 00000000..5ef0f56f --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/sshproxy.py @@ -0,0 +1,210 @@ +## +# Copyright 2016 Canonical Ltd. +# All rights reserved. +# +# 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. +## + +from charmhelpers.core import unitdata +from charmhelpers.core.hookenv import ( + action_fail, + action_get, + action_set, + config, + log, + status_set, + DEBUG, +) + +from charms.reactive.flags import register_trigger + +from charms.reactive import ( + clear_flag, + set_flag, + when, + when_not, + when_any, +) +import charms.sshproxy +import os +import subprocess + +# Register a trigger so that we can respond to config.changed, even if +# it's being cleared by another handler +register_trigger(when='config.changed', + set_flag='sshproxy.reconfigure') + + +# @when_any('config.changed', 'sshproxy.reconfigure') +@when_any('config.set.ssh-hostname', 'config.set.ssh-username', 'config.set.ssh-password', 'sshproxy.reconfigure') +def ssh_configured(): + """Check if charm is properly configured. + + Check to see if the charm is configured with SSH credentials. If so, + set a state flag that can be used to execute ssh-only actions. + + For example: + + @when('sshproxy.configured') + def run_remote_command(cmd): + ... + + @when_not('sshproxy.configured') + def run_local_command(cmd): + ... + """ + log("Checking sshproxy configuration", DEBUG) + cfg = config() + ssh_keys = ['ssh-hostname', 'ssh-username', + 'ssh-password', 'ssh-private-key'] + + if all(k in cfg for k in ssh_keys): + + # Store config in unitdata so it's accessible to sshproxy + db = unitdata.kv() + db.set('config', cfg) + + # Explicitly flush the kv so it's immediately available + db.flush() + + log("Verifying ssh credentials...", DEBUG) + (verified, output) = charms.sshproxy.verify_ssh_credentials() + if verified: + log("SSH credentials verified.", DEBUG) + set_flag('sshproxy.configured') + status_set('active', 'Ready!') + else: + clear_flag('sshproxy.configured') + status_set('blocked', "Remote machine not ready yet: {}".format(output)) + else: + log("No ssh credentials configured", DEBUG) + clear_flag('sshproxy.configured') + status_set('blocked', 'Invalid SSH credentials.') + + +def generate_ssh_key(): + """Generate a new 4096-bit rsa keypair. + + If there is an existing keypair for this unit, it will be overwritten. + """ + cfg = config() + if all(k in cfg for k in ['ssh-key-type', 'ssh-key-bits']): + keytype = cfg['ssh-key-type'] + bits = str(cfg['ssh-key-bits']) + privatekey = '/root/.ssh/id_juju_sshproxy' + publickey = "{}.pub".format(privatekey) + + if os.path.exists(privatekey): + os.remove(privatekey) + if os.path.exists(publickey): + os.remove(publickey) + + cmd = "ssh-keygen -t {} -b {} -N '' -f {}".format( + keytype, + bits, + privatekey + ) + + output, err = charms.sshproxy.run_local([cmd]) + if len(err) == 0: + return True + return False + + +@when('actions.generate-ssh-key') +def action_generate_ssh_key(): + """Generate a new 4096-bit rsa keypair. + + If there is an existing keypair for this unit, it will be overwritten. + """ + try: + if not generate_ssh_key(): + action_fail('Unable to generate ssh key.') + except subprocess.CalledProcessError as e: + action_fail('Command failed: %s (%s)' % + (' '.join(e.cmd), str(e.output))) + finally: + clear_flag('actions.generate-ssh-key') + + +def get_ssh_public_key(): + """Get the public SSH key of this unit.""" + publickey_path = '/root/.ssh/id_juju_sshproxy.pub' + publickey = None + if os.path.exists(publickey_path): + with open(publickey_path, 'r') as f: + publickey = f.read() + + return publickey + + +@when('actions.get-ssh-public-key') +def action_get_ssh_public_key(): + """Get the public SSH key of this unit.""" + try: + action_set({'pubkey': get_ssh_public_key()}) + except subprocess.CalledProcessError as e: + action_fail('Command failed: %s (%s)' % + (' '.join(e.cmd), str(e.output))) + finally: + clear_flag('actions.get-ssh-public-key') + + +@when('actions.verify-ssh-credentials') +def action_verify_ssh_credentials(): + """Verify the ssh credentials have been installed to the VNF. + + Attempts to run a stock command - `hostname` on the remote host. + """ + try: + (verified, output) = charms.sshproxy.verify_ssh_credentials() + action_set({ + 'output': output, + 'verified': verified, + }) + if not verified: + action_fail("Verification failed: {}".format( + output, + )) + finally: + clear_flag('actions.verify-ssh-credentials') + + +@when('actions.run') +def run_command(): + """Run an arbitrary command. + + Run an arbitrary command, either locally or over SSH with the configured + credentials. + """ + try: + cmd = action_get('command') + output, err = charms.sshproxy._run(cmd) + if len(err): + action_fail("Command '{}' returned error code {}".format(cmd, err)) + else: + action_set({'output': output}) + except subprocess.CalledProcessError as e: + action_fail('Command failed: %s (%s)' % + (' '.join(e.cmd), str(e.output))) + finally: + clear_flag('actions.run') + + +@when_not('sshproxy.installed') +def install_vnf_ubuntu_proxy(): + """Install and Configure SSH Proxy.""" + + log("Generating SSH key...", DEBUG) + generate_ssh_key() + set_flag('sshproxy.installed') diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/tid-jujuk8s.py b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/tid-jujuk8s.py new file mode 100644 index 00000000..21259cc9 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/tid-jujuk8s.py @@ -0,0 +1,699 @@ +from charmhelpers.core.hookenv import ( + action_get, + action_fail, + action_set, + status_set, + log, +) +from charms.reactive import ( + clear_flag, + set_flag, + when, + when_not, +) + +import charms.sshproxy +import sys, traceback +from jinja2 import Environment, FileSystemLoader +import time +import yaml + +class TidJujuK8sException(Exception): + pass + +@when_not('tid-jujuk8s.installed') +def install_tid_jujuk8s(): + set_flag('tid-jujuk8s.installed') + +@when('actions.setup-juju') +def setup_juju(): + err = '' + try: + cmd = "ip -4 -o a s ens3 | awk \\'{split($4,a,\\\"/\\\"); print a[1]}\\'" + log("setup-juju: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + mgmt_ip=result + + env = Environment(loader=FileSystemLoader('.')) + template = env.get_template('scripts/k8s-cloud-template.yaml') + output_from_parsed_template = template.render (controller_mgmt_ip_address = mgmt_ip) + temp_file="k8s-cloud.yaml" + with open(temp_file, "w") as fh: + fh.write(output_from_parsed_template) + fh.close() + + cfg = charms.sshproxy.get_config() + host = charms.sshproxy.get_host_ip() + user = cfg['ssh-username'] + charms.sshproxy.sftp('scripts/setup-juju.sh', '/home/ubuntu/setup-juju.sh', host, user) + charms.sshproxy.sftp('k8s-cloud.yaml', '/home/ubuntu/k8s-cloud.yaml', host, user) + + cmd = "chmod +x /home/ubuntu/setup-juju.sh; /home/ubuntu/setup-juju.sh > /dev/null && echo 'OK'" + log("setup-juju: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("setup-juju: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.setup-juju') + +@when('actions.add-machine') +def add_machines(): + err = '' + try: + machine = action_get('machine') + + cfg = charms.sshproxy.get_config() + host = charms.sshproxy.get_host_ip() + user = cfg['ssh-username'] + charms.sshproxy.sftp('scripts/add-machine.sh', '/home/ubuntu/add-machine.sh', host, user) + + cmd = "chmod +x /home/ubuntu/add-machine.sh" + log("add-machine: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + + cmd = "/home/ubuntu/add-machine.sh {} > /dev/null && echo 'OK'".format(machine) + log("add-machine: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("add-machine: added {}".format(machine)) + log("add-machine: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.add-machine') + +@when('actions.add-machines') +def add_machines(): + err = '' + try: + machines = [] + machines.append(action_get('machine1')) + machines.append(action_get('machine2')) + machines.append(action_get('machine3')) + machines.append(action_get('machine4')) + machines.append(action_get('machine5')) + machines.append(action_get('machine6')) + machines.append(action_get('machine7')) + machines.append(action_get('machine8')) + machines.append(action_get('machine9')) + machines.append(action_get('machine10')) + + cfg = charms.sshproxy.get_config() + host = charms.sshproxy.get_host_ip() + user = cfg['ssh-username'] + charms.sshproxy.sftp('scripts/add-machine.sh', '/home/ubuntu/add-machine.sh', host, user) + + cmd = "chmod +x /home/ubuntu/add-machine.sh" + log("add-machines: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + + number_of_machines = 0 + for m in machines: + if not m: + continue + cmd = "/home/ubuntu/add-machine.sh {} > /dev/null && echo 'OK'".format(m) + log("add-machines: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("add-machines: added {}".format(m)) + number_of_machines += 1 + log("add-machines: Checking whether all machines are ready") + timeout = 0 + while timeout <= 600: + try: + started = 0 + cmd = "/snap/bin/juju machines --format yaml" + log("add-machines: getting machines: " + cmd) + result, err = charms.sshproxy._run(cmd) + juju_machines = yaml.safe_load(result) + for k,v in juju_machines['machines'].items(): + if v.get('juju-status').get('current') == "started": + started += 1 + if started >= number_of_machines: + log("add-machines: {}/{} machines are ready".format(started,number_of_machines)) + break + log("add-machines: {}/{} machines are ready".format(started,number_of_machines)) + except: + log("Error. Command Failed." + str(err)) + time.sleep(20) + timeout += 20 + else: + log("add-machines: Machines are not ready after {} seconds.".format(timeout)) + raise TidJujuK8sException("Timeout when adding machines") + log("add-machines: DONE") + except TidJujuK8sException as toexception: + log("add-machines: TidJujuK8sException:" + str(toexception)) + action_fail('Timeout reached for adding machines:' + str(toexception)) + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.add-machines') + +@when('actions.deploy-bundle') +def deploy_bundle(): + err = '' + try: + cmd = "/snap/bin/juju machines --format yaml" + log("deploy-bundle: getting machines: " + cmd) + result, err = charms.sshproxy._run(cmd) + juju_machines = yaml.safe_load(result) + n_machines = len(juju_machines['machines']) + + bundle = action_get('bundle') + bundle_dict = {} + if bundle: + try: + bundle_dict = yaml.safe_load(bundle) + except yaml.YAMLError as exc: + raise TidJujuK8sException("Error loading the provided bundle " + bundle + ": " + str(exc)) + else: + with open("scripts/bundle-empty.yaml", 'r') as stream: + try: + bundle_dict = yaml.safe_load(stream) + except yaml.YAMLError as exc: + raise TidJujuK8sException("Error loading the default bundle bundle-empty.yaml: " + str(exc)) + if n_machines < 4: + raise TidJujuK8sException("Not possible to deploy a bundle when number of machines is lower than 4") + else: + n_etcd = 3 + n_masters = 2 + n_workers = n_machines - 1 + bundle_dict["machines"]={} + #bundle_dict["machines"].extend(map(str,range(n_machines))) + for i in range(n_machines): + bundle_dict["machines"][str(i)] = {} + bundle_dict["services"]["easyrsa"]["num_units"]=1 + bundle_dict["services"]["easyrsa"]["to"]=[] + bundle_dict["services"]["easyrsa"]["to"].append("0") + bundle_dict["services"]["kubeapi-load-balancer"]["num_units"]=1 + bundle_dict["services"]["kubeapi-load-balancer"]["to"]=[] + bundle_dict["services"]["kubeapi-load-balancer"]["to"].append("0") + bundle_dict["services"]["etcd"]["num_units"]=n_etcd + bundle_dict["services"]["etcd"]["to"]=[] + bundle_dict["services"]["etcd"]["to"].extend(map(str,range(0,n_etcd))) + bundle_dict["services"]["kubernetes-master"]["num_units"]=n_masters + bundle_dict["services"]["kubernetes-master"]["to"]=[] + bundle_dict["services"]["kubernetes-master"]["to"].extend(map(str,range(0,n_masters))) + bundle_dict["services"]["kubernetes-worker"]["num_units"]=n_workers + bundle_dict["services"]["kubernetes-worker"]["to"]=[] + bundle_dict["services"]["kubernetes-worker"]["to"].extend(map(str,range(1,n_workers+1))) + + with open("scripts/bundle.yaml", 'w') as stream: + try: + yaml.safe_dump(bundle_dict, stream) + except yaml.YAMLError as exc: + raise TidJujuK8sException("Error while dumping bundle_dict to bundle.yaml: " + str(exc)) + + cfg = charms.sshproxy.get_config() + host = charms.sshproxy.get_host_ip() + user = cfg['ssh-username'] + charms.sshproxy.sftp('scripts/bundle.yaml', '/home/ubuntu/bundle.yaml', host, user) + + existing_machines = [] + map_machines = "" + bundle_machine = 0 + for k in sorted(juju_machines['machines'].keys()): + map_machines = "{}{}={}".format(map_machines, bundle_machine, k) + bundle_machine += 1 + if bundle_machine < n_machines: + map_machines += "," + log("deploy-bundle: map_machines: " + map_machines) + + cmd = "/snap/bin/juju deploy ./bundle.yaml --map-machines=existing,{}".format(map_machines) + log("deploy-bundle: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("deploy-bundle: Checking whether all applications in the bundle are active") + timeout = 0 + while timeout <= 12000: + try: + cmd = "/snap/bin/juju status --format yaml" + log("deploy-bundle: getting status: " + cmd) + result, err = charms.sshproxy._run(cmd) + juju_status = yaml.safe_load(result) + for k,v in juju_status['applications'].items(): + if v.get('application-status').get('current') != 'active': + log('deploy-bundle: Application {} not active'.format(k)) + break + else: + log('deploy-bundle: All applications are active') + break + except: + log("Error. Command Failed." + str(err)) + time.sleep(20) + timeout += 20 + else: + log("deploy-bundle: Applications in the bundle are not ready after {} seconds.".format(timeout)) + raise TidJujuK8sException("Timeout when deploying bundle") + log("deploy-bundle: DONE") + except TidJujuK8sException as toexception: + log("deploy-bundle: TidJujuK8sException:" + str(toexception)) + action_fail('Timeout reached for deploying the bundle:' + str(toexception)) + log("deploy-bundle: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.deploy-bundle') + +@when('actions.undeploy-bundle') +def undeploy_bundle(): + ''' TODO: Not yet properly working + ''' + err = '' + try: + cmd = "/snap/bin/juju machines --format yaml" + log("undeploy-bundle: getting machines: " + cmd) + result, err = charms.sshproxy._run(cmd) + juju_machines = yaml.safe_load(result) + + n_machines = len(juju_machines['machines']) + cmd = "chmod +x /home/ubuntu/undeploy-bundle.sh; /home/ubuntu/undeploy-bundle.sh > /dev/null && echo 'OK'" + log("undeploy-bundle: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("undeploy-bundle: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.undeploy-bundle') + +@when('actions.remove-machines') +def remove_machines(): + ''' TODO: Not yet properly working + ''' + err = '' + try: + force = action_get('force') + + cmd = "/snap/bin/juju machines --format yaml" + log("remove-machines: getting machines: " + cmd) + result, err = charms.sshproxy._run(cmd) + juju_machines = yaml.safe_load(result) + number_of_machines = len(juju_machines['machines']) + + #cfg = charms.sshproxy.get_config() + #host = charms.sshproxy.get_host_ip() + #user = cfg['ssh-username'] + #charms.sshproxy.sftp('scripts/remove-machine.sh', '/home/ubuntu/remove-machine.sh', host, user) + + for m in juju_machines['machines']: + #cmd = "chmod +x /home/ubuntu/remove-machine.sh; /home/ubuntu/remove-machine.sh > /dev/null && echo 'OK'" + cmd = "/snap/bin/juju remove-machine {}".format(m) + if force: + cmd += " --force" + cmd += " > /dev/null && echo 'OK'" + log("remove-machine: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("remove-machines: Checking whether all machines were removed") + timeout = 0 + while timeout <= 600: + try: + started = 0 + cmd = "/snap/bin/juju machines --format yaml" + log("remove-machines: getting machines: " + cmd) + result, err = charms.sshproxy._run(cmd) + if result: + juju_machines = yaml.safe_load(result) + n_machines = len(juju_machines['machines']) + log("remove-machines: {}/{} machines are active".format(n_machines,number_of_machines)) + if n_machines == 0: + log("remove-machines: no machines".format(n_machines,number_of_machines)) + break + else: + log("remove-machines: no machines".format(n_machines,number_of_machines)) + break + except: + log("Error. Command Failed." + str(err)) + time.sleep(20) + timeout += 20 + else: + log("remove-machines: Machines were not removed after {} seconds.".format(timeout)) + raise TidJujuK8sException("Timeout when adding machines") + log("remove-machines: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.remove-machines') + +@when('actions.post-deploy') +def post_deploy(): + err = '' + try: + cfg = charms.sshproxy.get_config() + host = charms.sshproxy.get_host_ip() + user = cfg['ssh-username'] + charms.sshproxy.sftp('scripts/post-deploy.sh', '/home/ubuntu/post-deploy.sh', host, user) + + cmd = "chmod +x /home/ubuntu/post-deploy.sh; /home/ubuntu/post-deploy.sh > /dev/null && echo 'OK'" + log("post-deploy: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("post-deploy: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.post-deploy') + +@when('actions.init-helm') +def init_helm(): + err = '' + try: + cfg = charms.sshproxy.get_config() + host = charms.sshproxy.get_host_ip() + user = cfg['ssh-username'] + charms.sshproxy.sftp('scripts/init-helm.sh', '/home/ubuntu/init-helm.sh', host, user) + + cmd = "chmod +x /home/ubuntu/init-helm.sh; /home/ubuntu/init-helm.sh > /dev/null && echo 'OK'" + log("init-helm: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("init-helm: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.init-helm') + +@when('actions.install-openebs-chart') +def install_openebs_chart(): + err = '' + try: + cfg = charms.sshproxy.get_config() + host = charms.sshproxy.get_host_ip() + user = cfg['ssh-username'] + charms.sshproxy.sftp('scripts/openebs-storage-class.yaml', '/home/ubuntu/openebs-storage-class.yaml', host, user) + + cfg = charms.sshproxy.get_config() + host = charms.sshproxy.get_host_ip() + user = cfg['ssh-username'] + charms.sshproxy.sftp('scripts/install-openebs-chart.sh', '/home/ubuntu/install-openebs-chart.sh', host, user) + + cmd = "chmod +x /home/ubuntu/install-openebs-chart.sh; /home/ubuntu/install-openebs-chart.sh > /dev/null && echo 'OK'" + log("install-openebs-chart: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("install-openebs-chart: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.install-openebs-chart') + +@when('actions.install-openebs-kubectl') +def install_openebs_kubectl(): + err = '' + try: + cfg = charms.sshproxy.get_config() + host = charms.sshproxy.get_host_ip() + user = cfg['ssh-username'] + charms.sshproxy.sftp('scripts/openebs-storage-class.yaml', '/home/ubuntu/openebs-storage-class.yaml', host, user) + + cfg = charms.sshproxy.get_config() + host = charms.sshproxy.get_host_ip() + user = cfg['ssh-username'] + charms.sshproxy.sftp('scripts/install-openebs-kubectl.sh', '/home/ubuntu/install-openebs-kubectl.sh', host, user) + + cmd = "chmod +x /home/ubuntu/install-openebs-kubectl.sh; /home/ubuntu/install-openebs-kubectl.sh > /dev/null && echo 'OK'" + log("install-openebs-kubectl: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("install-openebs-kubectl: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.install-openebs-kubectl') + +@when('actions.install-chart') +def install_chart(): + err = '' + try: + chart = action_get('chart') + name = action_get('name') + namespace = action_get('namespace') + atomic = action_get('atomic') + values = action_get('values') + valuesFile = action_get('valuesFile') + + #cfg = charms.sshproxy.get_config() + #host = charms.sshproxy.get_host_ip() + #user = cfg['ssh-username'] + #charms.sshproxy.sftp('scripts/install-chart.sh', '/home/ubuntu/install-chart.sh', host, user) + + #cmd = "chmod +x /home/ubuntu/install-chart.sh; /home/ubuntu/install-chart.sh > /dev/null && echo 'OK'" + cmd = "/snap/bin/helm install {} -n {}".format(chart, name) + if namespace: + cmd += " --namespace {}".format(namespace) + if atomic: + cmd += " --atomic" + values_dict = {} + if values: + try: + values_dict = yaml.safe_load(stream) + except yaml.YAMLError as exc: + raise TidJujuK8sException("Error in values: " + str(exc)) + with open("myvalues.yaml", 'w') as stream: + try: + yaml.safe_dump(values_dict, stream) + except yaml.YAMLError as exc: + raise TidJujuK8sException("Error while dumping values_dict to myvalues.yaml: " + str(exc)) + valuesFile = "myvalues.yaml" + if valuesFile: + cfg = charms.sshproxy.get_config() + host = charms.sshproxy.get_host_ip() + user = cfg['ssh-username'] + charms.sshproxy.sftp(valuesFile, '/home/ubuntu/myvalues.yaml', host, user) + cmd += " -f /home/ubuntu/myvalues.yaml" + + log("install-chart: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("install-chart: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.install-chart') + +@when('actions.upgrade-release') +def upgrade_release(): + err = '' + try: + chart = action_get('chart') + name = action_get('name') + namespace = action_get('namespace') + atomic = action_get('atomic') + values = action_get('values') + valuesFile = action_get('valuesFile') + + #cfg = charms.sshproxy.get_config() + #host = charms.sshproxy.get_host_ip() + #user = cfg['ssh-username'] + #charms.sshproxy.sftp('scripts/upgrade-release.sh', '/home/ubuntu/upgrade-release.sh', host, user) + + #cmd = "chmod +x /home/ubuntu/upgrade-release.sh; /home/ubuntu/upgrade-release.sh > /dev/null && echo 'OK'" + cmd = "/snap/bin/helm upgrade {} {}".format(name, chart) + if namespace: + cmd += " --namespace {}".format(namespace) + if atomic: + cmd += " --atomic" + values_dict = {} + if values: + try: + values_dict = yaml.safe_load(stream) + except yaml.YAMLError as exc: + raise TidJujuK8sException("Error in values: " + str(exc)) + with open("myvalues.yaml", 'w') as stream: + try: + yaml.safe_dump(values_dict, stream) + except yaml.YAMLError as exc: + raise TidJujuK8sException("Error while dumping values_dict to myvalues.yaml: " + str(exc)) + valuesFile = "myvalues.yaml" + if valuesFile: + cfg = charms.sshproxy.get_config() + host = charms.sshproxy.get_host_ip() + user = cfg['ssh-username'] + charms.sshproxy.sftp(valuesFile, '/home/ubuntu/myvalues.yaml', host, user) + cmd += " -f /home/ubuntu/myvalues.yaml" + + log("upgrade-release: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("upgrade-release: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.upgrade-release') + +@when('actions.rollback-release') +def rollback_release(): + err = '' + try: + name = action_get('name') + revision = action_get('revision') + + #cfg = charms.sshproxy.get_config() + #host = charms.sshproxy.get_host_ip() + #user = cfg['ssh-username'] + #charms.sshproxy.sftp('scripts/rollback-release.sh', '/home/ubuntu/rollback-release.sh', host, user) + + #cmd = "chmod +x /home/ubuntu/rollback-release.sh; /home/ubuntu/rollback-release.sh > /dev/null && echo 'OK'" + cmd = "/snap/bin/helm rollback {}".format(name) + if revision: + cmd += " {}".format(revision) + log("rollback-release: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("rollback-release: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.rollback-release') + +@when('actions.delete-release') +def delete_release(): + err = '' + try: + name = action_get('name') + + #cfg = charms.sshproxy.get_config() + #host = charms.sshproxy.get_host_ip() + #user = cfg['ssh-username'] + #charms.sshproxy.sftp('scripts/delete-release.sh', '/home/ubuntu/delete-release.sh', host, user) + + #cmd = "chmod +x /home/ubuntu/delete-release.sh; /home/ubuntu/delete-release.sh > /dev/null && echo 'OK'" + cmd = "/snap/bin/helm delete --purge {}".format(name) + log("delete-release: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("delete-release: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.delete-release') + +@when('actions.add-repo') +def add_repo(): + err = '' + try: + name = action_get('name') + url = action_get('url') + + #cfg = charms.sshproxy.get_config() + #host = charms.sshproxy.get_host_ip() + #user = cfg['ssh-username'] + #charms.sshproxy.sftp('scripts/add-repo.sh', '/home/ubuntu/add-repo.sh', host, user) + + #cmd = "chmod +x /home/ubuntu/add-repo.sh; /home/ubuntu/add-repo.sh > /dev/null && echo 'OK'" + cmd = "/snap/bin/helm repo add {} {} > /dev/null && /snap/bin/helm repo update > /dev/null && echo 'OK'".format(name,url) + log("add-repo: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("add-repo: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.add-repo') + +@when('actions.remove-repo') +def remove_repo(): + err = '' + try: + name = action_get('name') + + #cfg = charms.sshproxy.get_config() + #host = charms.sshproxy.get_host_ip() + #user = cfg['ssh-username'] + #charms.sshproxy.sftp('scripts/remove-repo.sh', '/home/ubuntu/remove-repo.sh', host, user) + + #cmd = "chmod +x /home/ubuntu/remove-repo.sh; /home/ubuntu/remove-repo.sh > /dev/null && echo 'OK'" + cmd = "/snap/bin/helm repo remove {} > /dev/null && /snap/bin/helm repo update > /dev/null && echo 'OK'".format(name) + log("remove-repo: command to execute: " + cmd) + result, err = charms.sshproxy._run(cmd) + log("remove-repo: DONE") + except: + log("Error. Command Failed.") + action_fail('command failed:' + err) + exc_type, exc_value, exc_traceback = sys.exc_info() + err = traceback.format_exception(exc_type, exc_value, exc_traceback) + log(str(err)) + else: + action_set({'output': result}) + finally: + clear_flag('actions.remove-repo') + + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/vnfproxy.py b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/vnfproxy.py new file mode 100644 index 00000000..6616991d --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/reactive/vnfproxy.py @@ -0,0 +1,89 @@ +from charmhelpers.core.hookenv import ( + action_fail, + action_set, +) + +from charms.reactive import ( + when, + clear_flag, +) +import charms.sshproxy + + +@when('actions.reboot') +def reboot(): + err = '' + try: + result, err = charms.sshproxy._run("reboot") + except: + action_fail('command failed:' + err) + else: + action_set({'outout': result}) + finally: + clear_flag('actions.reboot') + + +############################################################################### +# Below is an example implementation of the start/stop/restart actions. # +# To use this, copy the below code into your layer and add the appropriate # +# command(s) necessary to perform the action. # +############################################################################### + +# @when('actions.start') +# def start(): +# err = '' +# try: +# cmd = "service myname start" +# result, err = charms.sshproxy._run(cmd) +# except: +# action_fail('command failed:' + err) +# else: +# action_set({'outout': result}) +# finally: +# clear_flag('actions.start') +# +# +# @when('actions.stop') +# def stop(): +# err = '' +# try: +# # Enter the command to stop your service(s) +# cmd = "service myname stop" +# result, err = charms.sshproxy._run(cmd) +# except: +# action_fail('command failed:' + err) +# else: +# action_set({'outout': result}) +# finally: +# clear_flag('actions.stop') +# +# +# @when('actions.restart') +# def restart(): +# err = '' +# try: +# # Enter the command to restart your service(s) +# cmd = "service myname restart" +# result, err = charms.sshproxy._run(cmd) +# except: +# action_fail('command failed:' + err) +# else: +# action_set({'outout': result}) +# finally: +# clear_flag('actions.restart') +# +# +# @when('actions.upgrade') +# def upgrade_vnf(): +# err = '' +# try: +# # Add the command(s) to perform a VNF software upgrade +# cmd = '' +# result, err = charms.sshproxy._run(cmd) +# except: +# action_fail('command failed:' + err) +# else: +# action_set({'outout': result}) +# finally: +# clear_flag('actions.upgrade') +# diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/requirements.txt b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/requirements.txt new file mode 100644 index 00000000..28ecacab --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/requirements.txt @@ -0,0 +1,2 @@ +flake8 +pytest diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/add-machine.sh b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/add-machine.sh new file mode 100755 index 00000000..4db9d6c9 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/add-machine.sh @@ -0,0 +1,4 @@ +#!/bin/bash +sshpass -posm4u ssh-copy-id -o "StrictHostKeyChecking no" -i /home/ubuntu/.local/share/juju/ssh/juju_id_rsa ubuntu@$1 +sudo su -l ubuntu -c "nohup /snap/bin/juju add-machine ssh:ubuntu@"$1" > /dev/null 2>&1 &" + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/add-repo.sh b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/add-repo.sh new file mode 100755 index 00000000..bfeb8565 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/add-repo.sh @@ -0,0 +1,6 @@ +#!/bin/bash +REPO_NAME=$1 +REPO_URL=$2 +helm repo add ${REPO_NAME} ${REPO_URL} +helm repo update + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/bundle-4machines.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/bundle-4machines.yaml new file mode 100644 index 00000000..9bb42cd9 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/bundle-4machines.yaml @@ -0,0 +1,134 @@ +description: A highly-available, production-grade Kubernetes cluster. +series: bionic +machines: + "0": + "1": + "2": + "3": +services: + containerd: + annotations: + gui-x: '475' + gui-y: '800' + charm: cs:~containers/containerd-20 + resources: {} + easyrsa: + annotations: + gui-x: '90' + gui-y: '420' + charm: cs:~containers/easyrsa-270 + constraints: root-disk=8G + num_units: 1 + resources: + easyrsa: 5 + to: + - "0" + etcd: + annotations: + gui-x: '800' + gui-y: '420' + charm: cs:~containers/etcd-449 + constraints: root-disk=8G + num_units: 3 + options: + channel: 3.2/stable + resources: + core: 0 + etcd: 3 + snapshot: 0 + to: + - "1" + - "2" + - "3" + flannel: + annotations: + gui-x: '475' + gui-y: '605' + charm: cs:~containers/flannel-438 + resources: + flannel-amd64: 394 + flannel-arm64: 390 + flannel-s390x: 377 + kubeapi-load-balancer: + annotations: + gui-x: '450' + gui-y: '250' + charm: cs:~containers/kubeapi-load-balancer-664 + constraints: root-disk=8G + expose: true + num_units: 1 + resources: {} + to: + - "0" + kubernetes-master: + annotations: + gui-x: '800' + gui-y: '850' + charm: cs:~containers/kubernetes-master-724 + constraints: cores=2 mem=4G root-disk=16G + num_units: 2 + options: + channel: 1.15/stable + resources: + cdk-addons: 0 + core: 0 + kube-apiserver: 0 + kube-controller-manager: 0 + kube-proxy: 0 + kube-scheduler: 0 + kubectl: 0 + to: + - "1" + - "2" + kubernetes-worker: + annotations: + gui-x: '90' + gui-y: '850' + charm: cs:~containers/kubernetes-worker-571 + constraints: cores=4 mem=4G root-disk=16G + expose: true + num_units: 3 + options: + channel: 1.15/stable + resources: + cni-amd64: 392 + cni-arm64: 383 + cni-s390x: 395 + core: 0 + kube-proxy: 0 + kubectl: 0 + kubelet: 0 + to: + - "1" + - "2" + - "3" +relations: +- - kubernetes-master:kube-api-endpoint + - kubeapi-load-balancer:apiserver +- - kubernetes-master:loadbalancer + - kubeapi-load-balancer:loadbalancer +- - kubernetes-master:kube-control + - kubernetes-worker:kube-control +- - kubernetes-master:certificates + - easyrsa:client +- - etcd:certificates + - easyrsa:client +- - kubernetes-master:etcd + - etcd:db +- - kubernetes-worker:certificates + - easyrsa:client +- - kubernetes-worker:kube-api-endpoint + - kubeapi-load-balancer:website +- - kubeapi-load-balancer:certificates + - easyrsa:client +- - flannel:etcd + - etcd:db +- - flannel:cni + - kubernetes-master:cni +- - flannel:cni + - kubernetes-worker:cni +- - containerd:containerd + - kubernetes-worker:container-runtime +- - containerd:containerd + - kubernetes-master:container-runtime + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/bundle-empty.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/bundle-empty.yaml new file mode 100644 index 00000000..7041dbef --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/bundle-empty.yaml @@ -0,0 +1,115 @@ +description: A highly-available, production-grade Kubernetes cluster. +series: bionic +machines: +services: + containerd: + annotations: + gui-x: '475' + gui-y: '800' + charm: cs:~containers/containerd-33 + resources: {} + easyrsa: + annotations: + gui-x: '90' + gui-y: '420' + charm: cs:~containers/easyrsa-278 + constraints: root-disk=8G + resources: + easyrsa: 5 + to: + etcd: + annotations: + gui-x: '800' + gui-y: '420' + charm: cs:~containers/etcd-460 + constraints: root-disk=8G + options: + channel: 3.2/stable + resources: + core: 0 + etcd: 3 + snapshot: 0 + to: + flannel: + annotations: + gui-x: '475' + gui-y: '605' + charm: cs:~containers/flannel-450 + resources: + flannel-amd64: 458 + flannel-arm64: 454 + flannel-s390x: 441 + kubeapi-load-balancer: + annotations: + gui-x: '450' + gui-y: '250' + charm: cs:~containers/kubeapi-load-balancer-682 + constraints: root-disk=8G + expose: true + resources: {} + to: + kubernetes-master: + annotations: + gui-x: '800' + gui-y: '850' + charm: cs:~containers/kubernetes-master-754 + constraints: cores=2 mem=4G root-disk=16G + options: + channel: 1.15/stable + resources: + cdk-addons: 0 + core: 0 + kube-apiserver: 0 + kube-controller-manager: 0 + kube-proxy: 0 + kube-scheduler: 0 + kubectl: 0 + to: + kubernetes-worker: + annotations: + gui-x: '90' + gui-y: '850' + charm: cs:~containers/kubernetes-worker-590 + constraints: cores=4 mem=4G root-disk=16G + expose: true + options: + channel: 1.15/stable + resources: + cni-amd64: 455 + cni-arm64: 446 + cni-s390x: 458 + core: 0 + kube-proxy: 0 + kubectl: 0 + kubelet: 0 + to: +relations: +- - kubernetes-master:kube-api-endpoint + - kubeapi-load-balancer:apiserver +- - kubernetes-master:loadbalancer + - kubeapi-load-balancer:loadbalancer +- - kubernetes-master:kube-control + - kubernetes-worker:kube-control +- - kubernetes-master:certificates + - easyrsa:client +- - etcd:certificates + - easyrsa:client +- - kubernetes-master:etcd + - etcd:db +- - kubernetes-worker:certificates + - easyrsa:client +- - kubernetes-worker:kube-api-endpoint + - kubeapi-load-balancer:website +- - kubeapi-load-balancer:certificates + - easyrsa:client +- - flannel:etcd + - etcd:db +- - flannel:cni + - kubernetes-master:cni +- - flannel:cni + - kubernetes-worker:cni +- - containerd:containerd + - kubernetes-worker:container-runtime +- - containerd:containerd + - kubernetes-master:container-runtime + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/bundle.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/bundle.yaml new file mode 100644 index 00000000..234393aa --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/bundle.yaml @@ -0,0 +1,113 @@ +description: A highly-available, production-grade Kubernetes cluster. +series: bionic +services: + containerd: + annotations: + gui-x: '475' + gui-y: '800' + charm: cs:~containers/containerd-33 + resources: {} + easyrsa: + annotations: + gui-x: '90' + gui-y: '420' + charm: cs:~containers/easyrsa-278 + constraints: root-disk=8G + num_units: 1 + resources: + easyrsa: 5 + etcd: + annotations: + gui-x: '800' + gui-y: '420' + charm: cs:~containers/etcd-460 + constraints: root-disk=8G + num_units: 3 + options: + channel: 3.2/stable + resources: + core: 0 + etcd: 3 + snapshot: 0 + flannel: + annotations: + gui-x: '475' + gui-y: '605' + charm: cs:~containers/flannel-450 + resources: + flannel-amd64: 458 + flannel-arm64: 454 + flannel-s390x: 441 + kubeapi-load-balancer: + annotations: + gui-x: '450' + gui-y: '250' + charm: cs:~containers/kubeapi-load-balancer-682 + constraints: root-disk=8G + expose: true + num_units: 1 + resources: {} + kubernetes-master: + annotations: + gui-x: '800' + gui-y: '850' + charm: cs:~containers/kubernetes-master-754 + constraints: cores=2 mem=4G root-disk=16G + num_units: 2 + options: + channel: 1.16/stable + resources: + cdk-addons: 0 + core: 0 + kube-apiserver: 0 + kube-controller-manager: 0 + kube-proxy: 0 + kube-scheduler: 0 + kubectl: 0 + kubernetes-worker: + annotations: + gui-x: '90' + gui-y: '850' + charm: cs:~containers/kubernetes-worker-590 + constraints: cores=4 mem=4G root-disk=16G + expose: true + num_units: 3 + options: + channel: 1.16/stable + resources: + cni-amd64: 455 + cni-arm64: 446 + cni-s390x: 458 + core: 0 + kube-proxy: 0 + kubectl: 0 + kubelet: 0 +relations: +- - kubernetes-master:kube-api-endpoint + - kubeapi-load-balancer:apiserver +- - kubernetes-master:loadbalancer + - kubeapi-load-balancer:loadbalancer +- - kubernetes-master:kube-control + - kubernetes-worker:kube-control +- - kubernetes-master:certificates + - easyrsa:client +- - etcd:certificates + - easyrsa:client +- - kubernetes-master:etcd + - etcd:db +- - kubernetes-worker:certificates + - easyrsa:client +- - kubernetes-worker:kube-api-endpoint + - kubeapi-load-balancer:website +- - kubeapi-load-balancer:certificates + - easyrsa:client +- - flannel:etcd + - etcd:db +- - flannel:cni + - kubernetes-master:cni +- - flannel:cni + - kubernetes-worker:cni +- - containerd:containerd + - kubernetes-worker:container-runtime +- - containerd:containerd + - kubernetes-master:container-runtime diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/delete-release.sh b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/delete-release.sh new file mode 100755 index 00000000..bce70257 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/delete-release.sh @@ -0,0 +1,4 @@ +#!/bin/bash +RELEASE=$1 +helm delete --purge ${RELEASE} + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/init-helm.sh b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/init-helm.sh new file mode 100755 index 00000000..58089ba7 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/init-helm.sh @@ -0,0 +1,11 @@ +#!/bin/bash +curl https://get.helm.sh/helm-v2.15.2-linux-amd64.tar.gz --output helm-v2.15.2.tar.gz +tar -zxvf helm-v2.15.2.tar.gz +sudo mv linux-amd64/helm /usr/local/bin/helm +rm -rf linux-amd64/ +rm -f helm-v2.15.2.tar.gz +/usr/local/bin/helm init +# Snap for helm currently uses version 3 of helm +#sudo snap install helm --classic +#/snap/bin/helm init + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/install-chart.sh b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/install-chart.sh new file mode 100755 index 00000000..d9f501a5 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/install-chart.sh @@ -0,0 +1,9 @@ +#!/bin/bash +CHART=$1 +VALUES_FILE=$2 +ADDITIONAL_OPTS="" +if [ $# -gt 2 ]; then + ADDITIONAL_OPTS="-n $3" +fi +helm install ${CHART} -f ${VALUES_FILE} --atomic ${ADDITIONAL_OPTS} + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/install-openebs-chart.sh b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/install-openebs-chart.sh new file mode 100755 index 00000000..8b715bbc --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/install-openebs-chart.sh @@ -0,0 +1,5 @@ +#!/bin/bash +/snap/bin/helm install --namespace openebs --name openebs stable/openebs +/snap/bin/kubectl apply -f /home/ubuntu/openebs-storage-class.yaml +/snap/bin/kubectl patch storageclass openebs-hostpath -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/install-openebs-kubectl.sh b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/install-openebs-kubectl.sh new file mode 100755 index 00000000..2284da07 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/install-openebs-kubectl.sh @@ -0,0 +1,5 @@ +#!/bin/bash +/snap/bin/kubectl apply -f https://openebs.github.io/charts/openebs-operator.yaml +/snap/bin/kubectl apply -f /home/ubuntu/openebs-storage-class.yaml +/snap/bin/kubectl patch storageclass openebs-hostpath -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/k8s-cloud-template.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/k8s-cloud-template.yaml new file mode 100644 index 00000000..2128f704 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/k8s-cloud-template.yaml @@ -0,0 +1,4 @@ +clouds: + k8s: + type: manual + endpoint: "ubuntu@{{ controller_mgmt_ip_address }}" diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/openebs-storage-class.yaml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/openebs-storage-class.yaml new file mode 100644 index 00000000..9b53b596 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/openebs-storage-class.yaml @@ -0,0 +1,15 @@ +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: openebs-hostpath + annotations: + openebs.io/cas-type: local + cas.openebs.io/config: | + - name: BasePath + value: "/var/openebs/local" + - name: StorageType + value: "hostpath" +provisioner: openebs.io/local +reclaimPolicy: Delete +volumeBindingMode: WaitForFirstConsumer + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/post-deploy.sh b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/post-deploy.sh new file mode 100755 index 00000000..bb228ab6 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/post-deploy.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Setup kubectl +mkdir -p ~/.kube +/snap/bin/juju scp kubernetes-master/0:config ~/.kube/config +sudo snap install kubectl --classic +# Allow privileges +/snap/bin/juju config kubernetes-master allow-privileged=true + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/remove-machine.sh b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/remove-machine.sh new file mode 100755 index 00000000..05a7907c --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/remove-machine.sh @@ -0,0 +1,2 @@ +#!/bin/bash + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/remove-repo.sh b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/remove-repo.sh new file mode 100755 index 00000000..48ddabc5 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/remove-repo.sh @@ -0,0 +1,5 @@ +#!/bin/bash +REPO_NAME=$1 +helm repo remove ${REPO_NAME} +helm repo update + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/rollback-release.sh b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/rollback-release.sh new file mode 100755 index 00000000..2fb99cea --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/rollback-release.sh @@ -0,0 +1,8 @@ +#!/bin/bash +RELEASE=$1 +REVISION="0" +if [ $# -gt 1 ]; then + REVISION=$2 +fi +helm rollback ${RELEASE} ${REVISION} + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/setup-juju.sh b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/setup-juju.sh new file mode 100755 index 00000000..ae0e8bcc --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/setup-juju.sh @@ -0,0 +1,20 @@ +#!/bin/bash +timeout=0 +while [ $timeout -lt 900 ]; do + if [ -f /home/ubuntu/tmp-cloudinit-installed.txt ]; then + break + fi + sleep 10 + timeout=$[$timeout + 10] +done +if [ timeout -eq 900 ]; then + >&2 echo "Cloudinit took longer than expected (> 900s). Not possible to start setup" + exit 1 +fi +cat /dev/zero | ssh-keygen -q -N "" +MGMT_IP=$(ip -4 -o a s ens3 | awk '{split($4,a,"/"); print a[1]}') +sshpass -posm4u ssh-copy-id -o "StrictHostKeyChecking no" ubuntu@${MGMT_IP} +/snap/bin/juju add-cloud --local k8s -f k8s-cloud.yaml +ssh-copy-id -i /home/ubuntu/.local/share/juju/ssh/juju_id_rsa ubuntu@${MGMT_IP} +/snap/bin/juju bootstrap k8s jujuk8s + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/test-elastic.sh b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/test-elastic.sh new file mode 100755 index 00000000..a1613738 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/test-elastic.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +CLUSTER_IP=192.168.0.151 +ELASTIC_PORT=30280 + +curl -XPUT 'http://'${CLUSTER_IP}':'${ELASTIC_PORT}'/blog/user/jose' -H 'Content-Type: application/json' -d '{ "name" : "Jose" }' + +curl -XPUT 'http://'${CLUSTER_IP}':'${ELASTIC_PORT}'/blogpost/post/1' -H 'Content-Type: application/json' -d ' +{ + "user": "jose", + "postDate": "2011-12-15", + "body": "Search is hard. Search should be easy." , + "title": "On search" +}' + +curl -XPUT 'http://'${CLUSTER_IP}':'${ELASTIC_PORT}'/blogpost/post/2' -H 'Content-Type: application/json' -d ' +{ + "user": "jose", + "postDate": "2011-12-12", + "body": "Distribution is hard. Distribution should be easy." , + "title": "On distributed search" +}' + +curl -XPUT 'http://'${CLUSTER_IP}':'${ELASTIC_PORT}'/blogpost/post/3' -H 'Content-Type: application/json' -d ' +{ + "user": "jose", + "postDate": "2011-12-10", + "body": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat" , + "title": "Lorem ipsum" +}' + + +curl -XGET 'http://'${CLUSTER_IP}':'${ELASTIC_PORT}'/blog/user/jose?pretty=true' +curl -XGET 'http://'${CLUSTER_IP}':'${ELASTIC_PORT}'/blogpost/post/1?pretty=true' +curl -XGET 'http://'${CLUSTER_IP}':'${ELASTIC_PORT}'/blogpost/post/2?pretty=true' +curl -XGET 'http://'${CLUSTER_IP}':'${ELASTIC_PORT}'/blogpost/post/3?pretty=true' +curl 'http://'${CLUSTER_IP}':'${ELASTIC_PORT}'/blogpost/post/_search?q=user:jose&pretty=true' + diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/test-spark-pi.py b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/test-spark-pi.py new file mode 100644 index 00000000..fc0f5070 --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/test-spark-pi.py @@ -0,0 +1,29 @@ +#!/usr/bin/python3 + +import pyspark +from pyspark.streaming import StreamingContext +# Kafka +from pyspark.streaming.kafka import KafkaUtils +import random +from operator import add + +#sc = pyspark.SparkContext('spark://192.168.0.151:32077') + +conf = pyspark.SparkConf().setAll([('spark.executor.memory', '2g'), ('spark.executor.cores', '1'), ('spark.cores.max', '1'), ('spark.driver.memory','2g')]) + +conf.setMaster("spark://192.168.0.151:32077") +sc = pyspark.SparkContext(conf=conf) + +# sc.setLogLevel("DEBUG") + +partitions = 100 +n = 100000 * partitions + +def f(_): + x = random.random() * 2 - 1 + y = random.random() * 2 - 1 + return 1 if x ** 2 + y ** 2 <= 1 else 0 + +count = sc.parallelize(range(1, n + 1), partitions).map(f).reduce(add) +print("Pi is roughly %f" % (4.0 * count / n)) +sc.stop() diff --git a/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/testNifiKafka.xml b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/testNifiKafka.xml new file mode 100644 index 00000000..cdc299ab --- /dev/null +++ b/k8s_jujucontroller_vnf/charms/tid-jujuk8s/scripts/testNifiKafka.xml @@ -0,0 +1,880 @@ + +