diff --git a/.gitignore b/.gitignore index e665f03..5d4e6e7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ id_rsa.pub *.patch *.egg-info/ .nox -.tox \ No newline at end of file +.tox +/stackhpc/github-secrets/* +/stackhpc/keys/* +force-teardown.sh diff --git a/stackhpc/README.md b/stackhpc/README.md new file mode 100644 index 0000000..c385cbc --- /dev/null +++ b/stackhpc/README.md @@ -0,0 +1,7 @@ +# Installation +1. Configure the files under deploy-zuul +2. Create github-secrets/webhook_token containg Github app webhook token +3. Create keys/github-key.pem containg Github app private key +4. Run install.sh +5. Once the zuul-web deployment has been created, run patch.sh +6. You may need to restart the nodepool-launcher-kubernetes deployment after the patches are complete diff --git a/stackhpc/database/mariadb-secret.yaml b/stackhpc/database/mariadb-secret.yaml new file mode 100644 index 0000000..fa9a273 --- /dev/null +++ b/stackhpc/database/mariadb-secret.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Secret +metadata: + name: mariadb-secret +stringData: + dburi: mariadb+pymysql://zuul:password@mysql:3306/zuul_db \ No newline at end of file diff --git a/stackhpc/database/mysql.yaml b/stackhpc/database/mysql.yaml new file mode 100644 index 0000000..114faa0 --- /dev/null +++ b/stackhpc/database/mysql.yaml @@ -0,0 +1,83 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + creationTimestamp: null + labels: + app.kubernetes.io/name: zuul + app.kubernetes.io/component: mysql + name: mysql +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: zuul + app.kubernetes.io/component: mysql + strategy: + type: Recreate + template: + metadata: + creationTimestamp: null + labels: + app.kubernetes.io/name: zuul + app.kubernetes.io/component: mysql + spec: + containers: + - env: + - name: MYSQL_DATABASE + value: zuul_db + - name: MYSQL_PASSWORD + value: password + - name: MYSQL_RANDOM_ROOT_PASSWORD + value: "yes" + - name: MYSQL_USER + value: "zuul" + image: mariadb:10.10 + name: mysql + ports: + - containerPort: 3306 + resources: {} + volumeMounts: + - mountPath: /var/lib/mysql + name: var-lib-mysql + hostname: mysql + restartPolicy: Always + volumes: + - name: var-lib-mysql + persistentVolumeClaim: + claimName: var-lib-mysql + +--- + +apiVersion: v1 +kind: Service +metadata: + creationTimestamp: null + labels: + app.kubernetes.io/name: zuul + app.kubernetes.io/component: mysql + name: mysql +spec: + ports: + - name: mysql + port: 3306 + targetPort: 3306 + selector: + app.kubernetes.io/name: zuul + app.kubernetes.io/component: mysql + +--- + +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + app.kubernetes.io/name: zuul + app.kubernetes.io/component: mysql + name: var-lib-mysql +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi diff --git a/stackhpc/deploy-zuul/main.yaml b/stackhpc/deploy-zuul/main.yaml new file mode 100644 index 0000000..043b1a9 --- /dev/null +++ b/stackhpc/deploy-zuul/main.yaml @@ -0,0 +1,14 @@ +- tenant: + name: my-tenant + exclude-unprotected-branches: false + source: + github: + config-projects: + - wtripp180901/zuul-config-test + untrusted-projects: + - wtripp180901/zuul-test-repo-a + - wtripp180901/zuul-test-repo-b + - wtripp180901/zuul-test-repo-c + opendev: + untrusted-projects: + - zuul/zuul-jobs diff --git a/stackhpc/deploy-zuul/nodepool.yaml b/stackhpc/deploy-zuul/nodepool.yaml new file mode 100644 index 0000000..1f3b416 --- /dev/null +++ b/stackhpc/deploy-zuul/nodepool.yaml @@ -0,0 +1,24 @@ +zookeeper-servers: + - host: zookeeper + port: 2281 + +zookeeper-tls: + cert: /var/certs/certs/client.pem + key: /var/certs/keys/clientkey.pem + ca: /var/certs/certs/cacert.pem + +labels: + - name: zuul-jobs-ns + - name: zuul-job-pod + +providers: + - name: kubernetes + driver: kubernetes + pools: + - name: main + labels: + - name: zuul-jobs-ns + type: namespace + - name: zuul-job-pod + type: pod + image: docker.io/rockylinux:8 diff --git a/stackhpc/deploy-zuul/zuul-permissions-role.yaml b/stackhpc/deploy-zuul/zuul-permissions-role.yaml new file mode 100644 index 0000000..ffa91c0 --- /dev/null +++ b/stackhpc/deploy-zuul/zuul-permissions-role.yaml @@ -0,0 +1,30 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: zuul-permissions +rules: +- apiGroups: + - "" + resources: + - namespaces + verbs: + - create + - get + - list + - patch + - apply + +--- + +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: zuul-perms-rb +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: zuul-permissions +subjects: + - kind: ServiceAccount + name: default + namespace: default \ No newline at end of file diff --git a/stackhpc/deploy-zuul/zuul.yaml b/stackhpc/deploy-zuul/zuul.yaml new file mode 100644 index 0000000..900fbf7 --- /dev/null +++ b/stackhpc/deploy-zuul/zuul.yaml @@ -0,0 +1,29 @@ +apiVersion: operator.zuul-ci.org/v1alpha2 +kind: Zuul +metadata: + name: zuul +spec: + executor: + count: 1 + # sshkey: + # secretName: executor-secret + scheduler: + config: + secretName: zuul-tenant-config + launcher: + config: + secretName: zuul-nodepool-config + web: + count: 1 + connections: + github: + driver: github + app_id: 382716 + app_key: /gh-keys/gh-key.pem + secretName: github-secrets + opendev: + driver: git + baseurl: https://opendev.org/ + database: + allowUnsafeConfig: True + secretName: mariadb-secret diff --git a/stackhpc/install.sh b/stackhpc/install.sh new file mode 100755 index 0000000..a5f7da5 --- /dev/null +++ b/stackhpc/install.sh @@ -0,0 +1,9 @@ +kubectl apply -f "database/*.yaml" +kubectl apply -f ../deploy/crds/zuul-ci_v1alpha2_zuul_crd.yaml +kubectl apply -f ../deploy/rbac-admin.yaml +kubectl apply -f ../deploy/operator.yaml +kubectl create secret generic zuul-nodepool-config --from-file=deploy-zuul/nodepool.yaml +kubectl create secret generic zuul-tenant-config --from-file=deploy-zuul/main.yaml +kubectl create secret generic github-secrets --from-file=github-secrets +kubectl create secret generic gh-key --from-file=keys +kubectl apply -f deploy-zuul/zuul.yaml diff --git a/stackhpc/patch-files/executor-key-patchfile.yaml b/stackhpc/patch-files/executor-key-patchfile.yaml new file mode 100644 index 0000000..51859c1 --- /dev/null +++ b/stackhpc/patch-files/executor-key-patchfile.yaml @@ -0,0 +1,12 @@ +spec: + template: + spec: + containers: + - name: executor + volumeMounts: + - name: gh-keys + mountPath: /gh-keys + volumes: + - name: gh-keys + secret: + secretName: gh-key diff --git a/stackhpc/patch-files/scheduler-key-patchfile.yaml b/stackhpc/patch-files/scheduler-key-patchfile.yaml new file mode 100644 index 0000000..74b2f35 --- /dev/null +++ b/stackhpc/patch-files/scheduler-key-patchfile.yaml @@ -0,0 +1,12 @@ +spec: + template: + spec: + containers: + - name: scheduler + volumeMounts: + - name: gh-keys + mountPath: /gh-keys + volumes: + - name: gh-keys + secret: + secretName: gh-key diff --git a/stackhpc/patch-files/web-key-patchfile.yaml b/stackhpc/patch-files/web-key-patchfile.yaml new file mode 100644 index 0000000..a051502 --- /dev/null +++ b/stackhpc/patch-files/web-key-patchfile.yaml @@ -0,0 +1,12 @@ +spec: + template: + spec: + containers: + - name: web + volumeMounts: + - name: gh-keys + mountPath: /gh-keys + volumes: + - name: gh-keys + secret: + secretName: gh-key diff --git a/stackhpc/patch-files/web-service-patchfile.yaml b/stackhpc/patch-files/web-service-patchfile.yaml new file mode 100644 index 0000000..7ba9685 --- /dev/null +++ b/stackhpc/patch-files/web-service-patchfile.yaml @@ -0,0 +1,3 @@ +spec: + type: LoadBalancer + loadBalancerIP: 192.171.169.119 diff --git a/stackhpc/patch-files/zookeeper-image-patchfile.yaml b/stackhpc/patch-files/zookeeper-image-patchfile.yaml new file mode 100644 index 0000000..540f03d --- /dev/null +++ b/stackhpc/patch-files/zookeeper-image-patchfile.yaml @@ -0,0 +1,6 @@ +spec: + template: + spec: + containers: + - name: zookeeper + image: "zookeeper:3.8.2" diff --git a/stackhpc/patch.sh b/stackhpc/patch.sh new file mode 100755 index 0000000..e79bdd5 --- /dev/null +++ b/stackhpc/patch.sh @@ -0,0 +1,5 @@ +kubectl patch deployment zuul-web --patch-file=patch-files/web-key-patchfile.yaml +kubectl patch statefulset zuul-scheduler --patch-file=patch-files/scheduler-key-patchfile.yaml +kubectl patch service zuul-web --patch-file=patch-files/web-service-patchfile.yaml +kubectl patch statefulset zuul-executor --patch-file=patch-files/executor-key-patchfile.yaml +kubectl patch statefulset zookeeper --patch-file=patch-files/zookeeper-image-patchfile.yaml