From 8229c1f6c3448f5b00d04cdf3928ca5776a44ff8 Mon Sep 17 00:00:00 2001 From: Ryan Hallisey Date: Mon, 22 Dec 2014 21:40:34 +0000 Subject: [PATCH] Start and stop scripts are outdated after Kubernetes update Kubernetes no longer uses 'kubecfg', but rather 'kubectl'. Therefore, the way that pods and services are being created needs to be changed. In order to create a pod, the parameter 'kind' needs to be set to 'pod' in the yaml file and the api version specified. The stop script now reads from k8s/{pod,service,replication}/ in order to stop all the started pods, services, and replication controllers. Change-Id: Ibd39fa402e9df883df83272c3aefbb69009dfbd2 --- k8s/pod/barbican-pod.yaml | 2 ++ k8s/pod/ceilometer-controller-pod.yaml | 4 +++- k8s/pod/glance-pod.yaml | 2 ++ k8s/pod/heat-pod.yaml | 2 ++ k8s/pod/horizon-pod.yaml | 2 ++ k8s/pod/keystone-pod.yaml | 2 ++ k8s/pod/mariadb-pod.yaml | 2 ++ k8s/pod/mongodb-pod.yaml | 2 ++ k8s/pod/neutron-network-pod.yaml | 2 ++ k8s/pod/neutron-server-pod.yaml | 2 ++ k8s/pod/nova-compute-pod.yaml | 2 ++ k8s/pod/nova-controller-pod.yaml | 4 +++- k8s/pod/rabbitmq-pod.yaml | 6 ++++-- k8s/pod/swift-pod.yaml | 2 ++ k8s/pod/zaqar-pod.yaml | 2 ++ k8s/replication/nova-compute-replication.yaml | 4 ++-- tools/start-all-pods | 2 +- tools/start-all-replications | 3 +-- tools/start-all-services | 2 +- tools/stop-all-pods | 21 ++++++++++++++++--- tools/stop-all-replications | 10 ++++++--- tools/stop-all-services | 9 +++++--- 22 files changed, 70 insertions(+), 19 deletions(-) diff --git a/k8s/pod/barbican-pod.yaml b/k8s/pod/barbican-pod.yaml index 1a79adbace..274f65bb65 100644 --- a/k8s/pod/barbican-pod.yaml +++ b/k8s/pod/barbican-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: containers: diff --git a/k8s/pod/ceilometer-controller-pod.yaml b/k8s/pod/ceilometer-controller-pod.yaml index ef94094f5b..fb387bb781 100644 --- a/k8s/pod/ceilometer-controller-pod.yaml +++ b/k8s/pod/ceilometer-controller-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: containers: @@ -50,6 +52,6 @@ desiredState: name: ceilometer-alarm id: ceilometer-1 version: v1beta1 -id: ceilometer +id: ceilometer-controller labels: name: ceilometer-controller diff --git a/k8s/pod/glance-pod.yaml b/k8s/pod/glance-pod.yaml index a7b8e29443..bf8c0d8cad 100644 --- a/k8s/pod/glance-pod.yaml +++ b/k8s/pod/glance-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: volumes: diff --git a/k8s/pod/heat-pod.yaml b/k8s/pod/heat-pod.yaml index a4eb0de57e..69babd33c9 100644 --- a/k8s/pod/heat-pod.yaml +++ b/k8s/pod/heat-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: containers: diff --git a/k8s/pod/horizon-pod.yaml b/k8s/pod/horizon-pod.yaml index a7f64c22e8..d25a96a0a7 100644 --- a/k8s/pod/horizon-pod.yaml +++ b/k8s/pod/horizon-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: containers: diff --git a/k8s/pod/keystone-pod.yaml b/k8s/pod/keystone-pod.yaml index cead5dd140..0b2b1a2acd 100644 --- a/k8s/pod/keystone-pod.yaml +++ b/k8s/pod/keystone-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: containers: diff --git a/k8s/pod/mariadb-pod.yaml b/k8s/pod/mariadb-pod.yaml index 493a393e61..4d5fb609d8 100644 --- a/k8s/pod/mariadb-pod.yaml +++ b/k8s/pod/mariadb-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: volumes: diff --git a/k8s/pod/mongodb-pod.yaml b/k8s/pod/mongodb-pod.yaml index 17663a7262..58d6b7be05 100644 --- a/k8s/pod/mongodb-pod.yaml +++ b/k8s/pod/mongodb-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: volumes: diff --git a/k8s/pod/neutron-network-pod.yaml b/k8s/pod/neutron-network-pod.yaml index a9fcfacd2a..834244c1a3 100644 --- a/k8s/pod/neutron-network-pod.yaml +++ b/k8s/pod/neutron-network-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: containers: diff --git a/k8s/pod/neutron-server-pod.yaml b/k8s/pod/neutron-server-pod.yaml index a8d18ee8ba..0a2879134f 100644 --- a/k8s/pod/neutron-server-pod.yaml +++ b/k8s/pod/neutron-server-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: volumes: diff --git a/k8s/pod/nova-compute-pod.yaml b/k8s/pod/nova-compute-pod.yaml index 6b7a72d573..37a3c2c8a7 100644 --- a/k8s/pod/nova-compute-pod.yaml +++ b/k8s/pod/nova-compute-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: containers: diff --git a/k8s/pod/nova-controller-pod.yaml b/k8s/pod/nova-controller-pod.yaml index 9034008874..393f58a1e5 100644 --- a/k8s/pod/nova-controller-pod.yaml +++ b/k8s/pod/nova-controller-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: containers: @@ -43,6 +45,6 @@ desiredState: privileged: true id: nova-1 version: v1beta1 -id: nova +id: nova-controller labels: name: nova-controller diff --git a/k8s/pod/rabbitmq-pod.yaml b/k8s/pod/rabbitmq-pod.yaml index c8d3d32b3a..676e7b2e59 100644 --- a/k8s/pod/rabbitmq-pod.yaml +++ b/k8s/pod/rabbitmq-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: containers: @@ -7,6 +9,6 @@ desiredState: - containerPort: 5672 id: rabbitmq-1 version: v1beta1 -id: rabbitmq-master +id: rabbitmq labels: - name: rabbitmq-master + name: rabbitmq diff --git a/k8s/pod/swift-pod.yaml b/k8s/pod/swift-pod.yaml index f8c3a057d6..0f61fe6343 100644 --- a/k8s/pod/swift-pod.yaml +++ b/k8s/pod/swift-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: containers: diff --git a/k8s/pod/zaqar-pod.yaml b/k8s/pod/zaqar-pod.yaml index b2564d52d7..3f4696c680 100644 --- a/k8s/pod/zaqar-pod.yaml +++ b/k8s/pod/zaqar-pod.yaml @@ -1,3 +1,5 @@ +apiVersion: v1beta1 +kind: Pod desiredState: manifest: containers: diff --git a/k8s/replication/nova-compute-replication.yaml b/k8s/replication/nova-compute-replication.yaml index 569436b3d6..0929d558be 100644 --- a/k8s/replication/nova-compute-replication.yaml +++ b/k8s/replication/nova-compute-replication.yaml @@ -30,14 +30,14 @@ desiredState: value: novadbpassword - name: KEYSTONE_ADMIN_TOKEN value: ADMINTOKEN - id: nova-compute-controller + id: nova-compute version: v1beta1 labels: name: nova-compute replicaSelector: name: nova-compute replicas: 6 -id: nova-compute-controller +id: nova-compute kind: ReplicationController labels: name: nova-compute diff --git a/tools/start-all-pods b/tools/start-all-pods index 089de76785..72c5807816 100755 --- a/tools/start-all-pods +++ b/tools/start-all-pods @@ -18,6 +18,6 @@ horizon ' for pod in $pods; do - kubecfg -c "k8s/pod/${pod}-pod.yaml" create pods + kubectl create -f "k8s/pod/${pod}-pod.yaml" done diff --git a/tools/start-all-replications b/tools/start-all-replications index b88572f4a2..a605d4fb75 100755 --- a/tools/start-all-replications +++ b/tools/start-all-replications @@ -7,7 +7,6 @@ nova-compute ' for svc in $services; do - kubecfg -c "k8s/replication/${svc}-replication.yaml" create \ - replicationControllers + kubectl create -f "k8s/replication/${svc}-replication.yaml" done diff --git a/tools/start-all-services b/tools/start-all-services index a78e9b1862..3c073465f6 100755 --- a/tools/start-all-services +++ b/tools/start-all-services @@ -22,6 +22,6 @@ horizon ' for svc in $services; do - kubecfg -c "k8s/service/${svc}-service.yaml" create services + kubectl create -f "k8s/service/${svc}-service.yaml" done diff --git a/tools/stop-all-pods b/tools/stop-all-pods index 4fe4b80d71..2a2d7d3abe 100755 --- a/tools/stop-all-pods +++ b/tools/stop-all-pods @@ -1,6 +1,21 @@ #!/bin/sh -kubecfg list pods | - awk 'NR>2 {print $1}' | - xargs -i kubecfg delete pods/{} +cd $(git rev-parse --show-toplevel) +# Delete the replication is not cleaning up its pods +# These pods need to be deleted according to their UUID +uuids=$(kubectl get pods -o json | jq '.[][].id' 2>/dev/null | grep -o -E '"[a-fA-F|0-9|\-]*' | cut -c 2- | grep '\-') + +for uuid in $uuids; do + if [ $uuid ]; then + kubectl delete pod $uuid + fi +done + +pods=$(kubectl get pods -o json| jq '.[][].id' 2>/dev/null) +# Removes quotes from jquery +pods=${pods//\"/} + +for pod in $pods; do + kubectl delete -f "k8s/pod/${pod}-pod.yaml" 2>/dev/null +done diff --git a/tools/stop-all-replications b/tools/stop-all-replications index aa2dc59540..6bea193fd7 100755 --- a/tools/stop-all-replications +++ b/tools/stop-all-replications @@ -1,6 +1,10 @@ #!/bin/sh -kubecfg list replicationControllers | - awk 'NR>2 {print $1}' | - xargs -i kubecfg delete replicationControllers/{} +cd $(git rev-parse --show-toplevel) + +replication_ctrs=$(kubectl get replicationController | awk 'NR>1 {print $1}') + +for replication_ctr in $replication_ctrs; do + kubectl delete -f "k8s/replication/${replication_ctr}-replication.yaml" +done diff --git a/tools/stop-all-services b/tools/stop-all-services index c76c244392..df5ce86d3e 100755 --- a/tools/stop-all-services +++ b/tools/stop-all-services @@ -1,6 +1,9 @@ #!/bin/sh -kubecfg list services | - awk 'NR>2 {print $1}' | - xargs -i kubecfg delete services/{} +cd $(git rev-parse --show-toplevel) +services=$(kubectl get services | awk 'NR>1 {print $1}') + +for service in $services; do + kubectl delete -f "k8s/service/${service}-service.yaml" 2>/dev/null +done