Skip to content

Commit

Permalink
Merge pull request apache#118 from animationzl/use-role-export-vexxho…
Browse files Browse the repository at this point in the history
…st-openrc

Use export-vexxhost-openrc role in related jobs
  • Loading branch information
kiwik authored Apr 3, 2018
2 parents bb88f51 + 6e6dc87 commit 05fc9f3
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 119 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
- hosts: all
become: yes
roles:
- export-vexxhost-openrc
tasks:
- name: Clean kubernetes deployments
shell:
Expand All @@ -8,7 +10,6 @@
set -x
pushd ${GOPATH}/src/k8s.io/kubernetes
cluster/kubectl.sh config use-context local
{ source "{{ ansible_user_dir }}/openrc";} 1> /dev/null 2>&1
ext_lb_svc_uid=$(cluster/kubectl.sh get services external-http-nginx-service -o=jsonpath='{.metadata.uid}') || true
int_lb_svc_uid=$(cluster/kubectl.sh get services internal-http-nginx-service -o=jsonpath='{.metadata.uid}') || true
Expand All @@ -33,4 +34,4 @@
done
executable: /bin/bash
chdir: '{{ zuul.project.src_dir }}'
environment: '{{ golang_env }}'
environment: '{{ golang_env | combine(vexxhost_openrc) }}'
151 changes: 52 additions & 99 deletions playbooks/cloud-provider-openstack-acceptance-test-lb-octavia/run.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,24 @@
- name: Set up Kubernetes local cluster
hosts: all
roles:
- install-k8s-jobs-dependences
become: yes
roles:
- export-vexxhost-openrc
tasks:
- name: Set up Kubernetes local cluster
shell:
cmd: |
set -x
set -e
set -o pipefail
apt-get install python-pip -y
pip install -U python-openstackclient python-octaviaclient python-neutronclient
cat << EOF >> "{{ ansible_user_dir }}/openrc"
export OS_DOMAIN_NAME=$(echo '{{ vexxhost_credentials.user_domain_name }}')
export OS_AUTH_TYPE=$(echo '{{ vexxhost_credentials.auth_type }}')
export OS_IDENTITY_API_VERSION=$(echo '{{ vexxhost_credentials.identity_api_version }}')
export OS_VOLUME_API_VERSION=$(echo '{{ vexxhost_credentials.volume_api_version }}')
export OS_INTERFACE=$(echo '{{ vexxhost_credentials.interface }}')
export OS_AUTH_URL=$(echo '{{ vexxhost_credentials.auth_url }}')
export OS_PROJECT_ID=$(echo '{{ vexxhost_credentials.project_id }}')
export OS_PROJECT_NAME=$(echo '{{ vexxhost_credentials.project_name }}')
export OS_USER_DOMAIN_NAME=$(echo '{{ vexxhost_credentials.user_domain_name }}')
export OS_PROJECT_DOMAIN_ID=$(echo '{{ vexxhost_credentials.project_domain_id }}')
export OS_USERNAME=$(echo '{{ vexxhost_credentials.username }}')
export OS_PASSWORD=$(echo '{{ vexxhost_credentials.password }}')
export OS_REGION_NAME=$(echo '{{ vexxhost_credentials.region_name }}')
EOF
{ source "{{ ansible_user_dir }}/openrc";} 1> /dev/null 2>&1
if [[ ! -d "/etc/kubernetes/" ]]; then
sudo mkdir -p /etc/kubernetes/
fi
chown zuul /etc/kubernetes/
# Create cloud-config
mkdir -p /etc/kubernetes/
cat << EOF >> /etc/kubernetes/cloud-config
[Global]
domain-name = ${OS_PROJECT_DOMAIN_NAME-$OS_PROJECT_DOMAIN_ID}
domain-name = $OS_USER_DOMAIN_NAME
tenant-id = $OS_PROJECT_ID
auth-url = $OS_AUTH_URL
password = $OS_PASSWORD
Expand All @@ -45,63 +29,41 @@
subnet-id = $(openstack network list --internal -f value -c Subnets | head -n 1)
[BlockStorage]
bs-version = v2
ignore-volume-az = yes
EOF
set -x
make depend
make build
mkdir -p "{{ ansible_user_dir }}/.kube"
export API_HOST_IP="172.17.0.1"
# Go where we cloned kubernetes repository
cd $GOPATH/src/k8s.io/kubernetes/
export API_HOST_IP=$(ifconfig | awk '/^docker0/ {getline; print $2}' | awk -F ':' '{print $2}')
export KUBELET_HOST="0.0.0.0"
echo "Stopping firewall and allow all traffic..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
export ALLOW_SECURITY_CONTEXT=true
export ENABLE_CRI=false
export ENABLE_HOSTPATH_PROVISIONER=true
export ENABLE_SINGLE_CA_SIGNER=true
# export KUBE_ENABLE_CLUSTER_DASHBOARD=true
export KUBE_ENABLE_CLUSTER_DNS=false
export LOG_LEVEL=10
# we want to use the openstack cloud provider
export LOG_LEVEL=4
# We want to use the openstack cloud provider
export CLOUD_PROVIDER=openstack
# we want to run a separate cloud-controller-manager for openstack
# We want to run a separate cloud-controller-manager for openstack
export EXTERNAL_CLOUD_PROVIDER=true
# DO NOT change the location of the cloud-config file. It is important for the old cinder provider to work
export CLOUD_CONFIG=/etc/kubernetes/cloud-config
# specify the OCCM binary
export EXTERNAL_CLOUD_PROVIDER_BINARY="{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/openstack-cloud-controller-manager"
# Cleanup some directories just in case
sudo rm -rf /var/lib/kubelet/*
# Specify the OCCM binary
export EXTERNAL_CLOUD_PROVIDER_BINARY='{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/openstack-cloud-controller-manager'
# location of where the kubernetes processes log their output
mkdir -p "{{ ansible_user_dir }}/workspace/logs/kubernetes"
export LOG_DIR="{{ ansible_user_dir }}/workspace/logs/kubernetes"
mkdir -p '{{ ansible_user_dir }}/workspace/logs/kubernetes'
export LOG_DIR='{{ ansible_user_dir }}/workspace/logs/kubernetes'
# We need this for one of the conformance tests
export ALLOW_PRIVILEGED=true
# Just kick off all the processes and drop down to the command line
export ENABLE_DAEMON=true
# We need the hostname to match the name of the vm started by openstack
export HOSTNAME_OVERRIDE=$(curl http://169.254.169.254/openstack/latest/meta_data.json | python -c "import sys, json; print json.load(sys.stdin)['name']")
pushd ${GOPATH}/src/k8s.io/kubernetes
export MAX_TIME_FOR_URL_API_SERVER=5
# -E preserves the current env vars, but we need to special case PATH
sudo -E PATH=$PATH SHELLOPTS=$SHELLOPTS ./hack/local-up-cluster.sh -O
# sudo of local-up-cluster mucks with permissions
sudo chmod -R 777 "{{ ansible_user_dir }}/.kube"
sudo chmod 777 /var/run/kubernetes/client-admin.key
# set up the config we need for kubectl to work
cluster/kubectl.sh config set-cluster local --server=https://localhost:6443 --certificate-authority=/var/run/kubernetes/server-ca.crt
cluster/kubectl.sh config set-credentials myself --client-key=/var/run/kubernetes/client-admin.key --client-certificate=/var/run/kubernetes/client-admin.crt
Expand All @@ -116,47 +78,38 @@
cluster/kubectl.sh create clusterrolebinding --user system:serviceaccount:kube-system:shared-informers kube-system-cluster-admin-5 --clusterrole cluster-admin
cluster/kubectl.sh create clusterrolebinding --user system:kube-controller-manager kube-system-cluster-admin-6 --clusterrole cluster-admin
cluster/kubectl.sh create -f "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/examples/loadbalancers/external-http-nginx.yaml"
cluster/kubectl.sh create -f "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/examples/loadbalancers/internal-http-nginx.yaml"
for i in $(seq 1 120); do
if [ -z "${external_lb_ip}" ]; then
external_lb_ip=$(./cluster/kubectl.sh describe services external-http-nginx-service |grep "LoadBalancer Ingress" | awk -F ' ' '{print $3}')
fi
if [ -z "${internal_lb_ip}" ]; then
internal_lb_ip=$(./cluster/kubectl.sh describe services internal-http-nginx-service |grep "LoadBalancer Ingress" | awk -F ' ' '{print $3}')
fi
if [ -n "${external_lb_ip}" -a -n "${internal_lb_ip}" ]; then
break
fi
echo "Waiting for deploying loadbalancer service on try ${i} ..."
sleep 5
# Run test
for test_case in internal external
do
test_file="{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/examples/loadbalancers/${test_case}-http-nginx.yaml"
service_name="${test_case}-http-nginx-service"
# Delete fake floating-network-id to use the default one in cloud config
sed -i '/loadbalancer.openstack.org/d' "$test_file"
cluster/kubectl.sh create -f "$test_file"
if ! service_name="$service_name" timeout 300 bash -c '
while :
do
[[ -n $(cluster/kubectl.sh describe service "$service_name" | awk "/LoadBalancer Ingress/ {print \$3}") ]] && break
sleep 1
done
'
then
echo "Timed out to wait for $test_case loadbalancer services deployment!"
cluster/kubectl.sh describe pods
cluster/kubectl.sh describe services
exit 1
fi
ingress_ip=$(cluster/kubectl.sh describe service "$service_name" | awk "/LoadBalancer Ingress/ {print \$3}")
if curl --retry 5 --retry-max-time 30 "http://$ingress_ip" | grep 'Welcome to nginx'
then
echo "$test_case lb services launched sucessfully!"
else
echo "$test_case lb services launched failed!"
exit 1
fi
done
if [ -z "${external_lb_ip}" -o -z "${internal_lb_ip}" ]; then
echo "Timed out to wait for loadbalancer services deployment!"
cluster/kubectl.sh describe pods
cluster/kubectl.sh describe services
exit 1
fi
if curl --retry 5 --retry-max-time 30 http://${external_lb_ip} |grep "Welcome to nginx"
then
echo "External LB services launched sucessfully!"
else
echo "External LB services launched failed!"
exit 1
fi
if curl --retry 5 --retry-max-time 30 http://${internal_lb_ip} |grep "Welcome to nginx"
then
echo "Internal LB services launched sucessfully!"
else
echo "Internal LB services launched failed!"
exit 1
fi
popd
executable: /bin/bash
chdir: '{{ zuul.project.src_dir }}'
environment: '{{ golang_env }}'
environment: '{{ golang_env | combine(vexxhost_openrc) }}'
19 changes: 4 additions & 15 deletions playbooks/cloud-provider-openstack-unittest/run.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
- hosts: all
become: yes
roles:
- export-vexxhost-openrc
tasks:
- shell:
cmd: |
# Use echo to delete extra spaces
export OS_AUTH_TYPE=$(echo '{{ vexxhost_credentials.auth_type }}')
export OS_IDENTITY_API_VERSION=$(echo '{{ vexxhost_credentials.identity_api_version }}')
export OS_VOLUME_API_VERSION=$(echo '{{ vexxhost_credentials.volume_api_version }}')
export OS_INTERFACE=$(echo '{{ vexxhost_credentials.interface }}')
export OS_AUTH_URL=$(echo '{{ vexxhost_credentials.auth_url }}')
export OS_PROJECT_ID=$(echo '{{ vexxhost_credentials.project_id }}')
export OS_PROJECT_NAME=$(echo '{{ vexxhost_credentials.project_name }}')
export OS_USER_DOMAIN_NAME=$(echo '{{ vexxhost_credentials.user_domain_name }}')
export OS_PROJECT_DOMAIN_ID=$(echo '{{ vexxhost_credentials.project_domain_id }}')
export OS_USERNAME=$(echo '{{ vexxhost_credentials.username }}')
export OS_PASSWORD=$(echo '{{ vexxhost_credentials.password }}')
export OS_REGION_NAME=$(echo '{{ vexxhost_credentials.region_name }}')
set -x
set -e
set -o pipefail
go get -u github.com/Masterminds/glide
TESTARGS='-v' make test 2>&1 | tee $TEST_RESULTS_TXT
executable: /bin/bash
chdir: '{{ zuul.project.src_dir }}'
environment: '{{ golang_env }}'
environment: '{{ golang_env | combine(vexxhost_openrc) }}'
5 changes: 2 additions & 3 deletions zuul.d/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,13 @@

- job:
name: cloud-provider-openstack-acceptance-test-lb-octavia
parent: golang-test
parent: cloud-provider-openstack-acceptance-test
description: |
Run acceptance tests of cloud-provider-openstack repo with LBaaS scenario against vexxhost cloud
Run lb acceptance tests of cloud-provider-openstack
run: playbooks/cloud-provider-openstack-acceptance-test-lb-octavia/run.yaml
post-run: playbooks/cloud-provider-openstack-acceptance-test-lb-octavia/post.yaml
secrets:
- vexxhost_credentials
nodeset: ubuntu-xenial-vexxhost

- job:
name: cloud-provider-openstack-acceptance-test-keystone-authentication-authorization
Expand Down

0 comments on commit 05fc9f3

Please sign in to comment.