Configure .kube/config on bridge

Add the gitea k8s cluster to root's .kube/config file on bridge.

The default context does not exist in order to force us to explicitly
specify a context for all commands (so that we do not inadvertently
deploy something on the wrong k8s cluster).

Change-Id: I53368c76e6f5b3ab45b1982e9a977f9ce9f08581
This commit is contained in:
James E. Blair 2019-02-06 15:38:10 -08:00
parent 40cc016ce2
commit 7610682b6f
13 changed files with 56 additions and 10 deletions

View File

@ -2,14 +2,17 @@
tasks:
- name: Set up gitea namespace
k8s:
context: gitea
state: present
definition: "{{ lookup('template', 'k8s/namespace.yaml') | from_yaml }}"
- name: Set up gitea secrets
k8s:
context: gitea
state: present
definition: "{{ lookup('template', 'k8s/secret.yaml') | from_yaml }}"
- name: Set up gitea configmap
k8s:
context: gitea
state: present
definition:
apiVersion: v1
@ -23,14 +26,17 @@
app.ini.j2: "{{ lookup('file', 'app.ini.j2') }}"
- name: Set up gitea deployment
k8s:
context: gitea
state: present
definition: "{{ lookup('template', 'k8s/deployment.yaml') | from_yaml }}"
- name: Set up gitea service
k8s:
context: gitea
state: present
definition: "{{ lookup('template', 'k8s/service.yaml') | from_yaml }}"
- name: Get service IP
k8s:
context: gitea
namespace: gitea
kind: Service
name: gitea-service
@ -57,7 +63,7 @@
- "app = gitea"
register: gitea_pods
- name: Create root user
command: "kubectl exec {{ gitea_pods.resources[0].metadata.name }} -n gitea -c gitea -- gitea admin create-user --name root --password {{ gitea_root_password }} --email {{ gitea_root_email }} --admin"
command: "kubectl --context gitea exec {{ gitea_pods.resources[0].metadata.name }} -n gitea -c gitea -- gitea admin create-user --name root --password {{ gitea_root_password }} --email {{ gitea_root_email }} --admin"
no_log: true
- name: Check if gerrit user exists
uri:

View File

@ -36,4 +36,4 @@
- name: Adjust repo settings
when: "sql_statement is defined"
command: |
kubectl exec gitea-pxc-0 -c database -n gitea-db -- mysql gitea -e '{{ sql_statement }}'
kubectl --context gitea exec gitea-pxc-0 -c database -n gitea-db -- mysql gitea -e '{{ sql_statement }}'

View File

@ -2,45 +2,54 @@
tasks:
- name: Set up cinder storage class
k8s:
context: gitea
state: present
definition: "{{ lookup('file', 'storage-class.yaml') | from_yaml }}"
- name: Set up gitea-db namespace
k8s:
context: gitea
state: present
definition: "{{ lookup('template', 'gitea-db-namespace.yaml') | from_yaml }}"
- name: Set up gitea-db secrets
k8s:
context: gitea
state: present
definition: "{{ lookup('template', 'secrets.yaml') | from_yaml }}"
- name: Set up gitea-db mysql config configmap
k8s:
context: gitea
state: present
definition: "{{ lookup('file', 'config-map_mysql-config.yaml') | from_yaml }}"
- name: Set up gitea-db startup scripts configmap
k8s:
context: gitea
state: present
definition: "{{ lookup('file', 'config-map_startup-scripts.yaml') | from_yaml }}"
- name: Set up gitea-db xtradb cluster statefulset
k8s:
context: gitea
state: present
definition: "{{ lookup('file', 'statefulset.yaml') | from_yaml }}"
- name: Set up gitea-db metrics service
k8s:
context: gitea
state: present
definition: "{{ lookup('file', 'service-metrics.yaml') | from_yaml }}"
- name: Set up gitea-db database service
k8s:
context: gitea
state: present
definition: "{{ lookup('file', 'service-percona.yaml') | from_yaml }}"
- name: Set up gitea-db galera replication service
k8s:
context: gitea
state: present
definition: "{{ lookup('file', 'service-repl.yaml') | from_yaml }}"

View File

@ -8,7 +8,7 @@
# into single document files is lame.
- name: Set up cinder storage class
command: |
kubectl apply -f rook-operator.yaml
kubectl apply -f rook-cluster.yaml
kubectl apply -f rook-toolbox.yaml
kubectl apply -f rook-filesystem.yaml
kubectl --context gitea apply -f rook-operator.yaml
kubectl --context gitea apply -f rook-cluster.yaml
kubectl --context gitea apply -f rook-toolbox.yaml
kubectl --context gitea apply -f rook-filesystem.yaml

View File

@ -17,7 +17,9 @@
- snmpd
- hosts: bridge.openstack.org:!disabled
name: "Base: configure OpenStackSDK on bridge"
name: "Base: configure cloud credentials on bridge"
roles:
- configure-kubectl
tasks:
- include_role:
name: configure-openstacksdk

View File

@ -1,2 +1,3 @@
ansible_python_interpreter: python3
bastion_key_exclusive: false
kube_config_template: clouds/bridge_kube_config.yaml.j2

View File

@ -1,6 +1,6 @@
Configure kube config files
Configure kubernetes files needed by nodepool.
Configure kubernetes files needed by kubectl.
**Role Variables**

View File

@ -18,5 +18,6 @@
- name: Install cinder storage class
k8s:
context: gitea
state: present
definition: "{{ lookup('file', 'k8s/storage-class.yaml') | from_yaml }}"

View File

@ -0,0 +1,19 @@
apiVersion: v1
kind: Config
current-context: default # This context does not exist
preferences: {}
clusters:
- name: gitea
cluster:
server: https://38.108.68.20:6443
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRFNU1ERXdPREV6TURRd05sb1hEVEk1TURFd05URXpNRFF3Tmxvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBT3loCkxQWjdWeU42YzN5a0QwWFBvM3c1enFRamNXeGVZRWVpMHhYTEV1SDA2anpGdXUwV1ZFWmd2ais3dEcvMnZiRDMKdlBGUmE5ZHpyelBjRkk5OHJPR2JlTjBGTFJYaHVYR0ZibDR6L3hoWHZHYVViZ2JRT0gvNDVzek5DOUltRWtEeQpRU1Zsa1EyOHl4Zmo4a2lwUTJocEk5MHNpSG05L1lnSjhrMHVhTEF4MmgvQnRwOUJPNVFtOEw0SUVyUThFUHZ0Cm1XMEROWlp3RDE3OEcrZUx2Ym9qbnhPaklYVmNMMTZFcWROSzRiMTZwSTVFa1RlT2FqSnowdWYvUlpCdzNUTCsKWForamdKV2I3VTVEU04wbndFVUlPTXBJWmtDcGVvbHFkRmF0eG93SUdaOFU2Q3BsbUlJMDBnYTBWTlpwZnRNRgpKdDdsM094YXlPaUNNdllSVVNFQ0F3RUFBYU1qTUNFd0RnWURWUjBQQVFIL0JBUURBZ0trT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7 +11,7 @@ nodepool_internap_project: project
nodepool_vexxhost_username: user
nodepool_vexxhost_password: password
nodepool_vexxhost_project: project
nodepool_vexxhost_kube_key: k8s_key
nodepool_vexxhost_kube_key: nodepool_k8s_key
nodepool_citycloud_username: user
nodepool_citycloud_password: password
nodepool_linaro_username: user

View File

@ -58,3 +58,4 @@ clouds:
openstackzuul_arm64ci_username: user
openstackzuul_arm64ci_password: password
openstackzuul_arm64ci_project_name: project
gitea_kube_key: gitea_k8s_key

View File

@ -65,3 +65,10 @@ def test_ara(host):
assert ara.rc == 0
database = host.file('/var/cache/ansible/ara.sqlite')
assert database.exists
def test_kube_config(host):
kubeconfig = host.file('/root/.kube/config')
assert kubeconfig.exists
assert b'gitea_k8s_key' in kubeconfig.content

View File

@ -27,4 +27,4 @@ def test_kube_config(host):
kubeconfig = host.file('/home/nodepool/.kube/config')
assert kubeconfig.exists
assert b'k8s_key' in kubeconfig.content
assert b'nodepool_k8s_key' in kubeconfig.content