From d6350327e94ac606308e0ccca2404d23bb8d532e Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Wed, 12 May 2021 22:47:46 +1000 Subject: [PATCH] CI: Add packer Ubuntu 16.04 helm jobs Signed-off-by: Anil Belur Change-Id: Iab3aa48f618dde75d187d2255fc0e4c4751dad56 --- jjb/releng-packer-jobs.yaml | 20 +++++++ packer/provision/helm.yaml | 116 ++++++++++++++++++++++++++++++++++++ packer/templates/helm.json | 61 +++++++++++++++++++ 3 files changed, 197 insertions(+) create mode 100644 packer/provision/helm.yaml create mode 100644 packer/templates/helm.json diff --git a/jjb/releng-packer-jobs.yaml b/jjb/releng-packer-jobs.yaml index 094056b85..14ac0a6aa 100644 --- a/jjb/releng-packer-jobs.yaml +++ b/jjb/releng-packer-jobs.yaml @@ -120,6 +120,26 @@ templates: docker update-cloud-image: true +- project: + name: packer-helm-jobs + jobs: + - gerrit-packer-merge + - gerrit-packer-verify-build + + project: releng/builder + project-name: builder + branch: master + archive-artifacts: "**/*.log" + + build-node: centos7-builder-2c-1g + build-timeout: 60 + cron: "00 H 1 * *" + + platforms: + - ubuntu-18.04 + templates: helm + update-cloud-image: true + - project: name: packer-mininet-ovs-2.8-jobs jobs: diff --git a/packer/provision/helm.yaml b/packer/provision/helm.yaml new file mode 100644 index 000000000..7b01c2203 --- /dev/null +++ b/packer/provision/helm.yaml @@ -0,0 +1,116 @@ +--- +- import_playbook: ../common-packer/provision/docker.yaml + +- hosts: all + become_user: root + become_method: sudo + + vars: + kubectl_version: 1.15.11 + helm_version: 2.16.6 + helm3_3_version: 3.3.4 + helm3_5_version: 3.5.1 + chartmuseum_version: 0.12.0 + + tasks: + - name: "Install kubectl {{kubectl_version}}" + get_url: + url: "https://storage.googleapis.com/kubernetes-release/release/v{{kubectl_version}}/bin/linux/amd64/kubectl" + dest: /usr/local/bin/kubectl + mode: 0775 + become: yes + + - name: "Install Helm {{helm_version}}" + block: + - name: "Fetch tar.gz for {{helm_version}}" + get_url: + url: "http://storage.googleapis.com/kubernetes-helm/helm-v{{helm_version}}-linux-amd64.tar.gz" + dest: "/tmp/helm-v{{helm_version}}-linux-amd64.tar.gz" + - name: "Unarchive {{helm_version}}" + unarchive: + src: "/tmp/helm-v{{helm_version}}-linux-amd64.tar.gz" + dest: /tmp + remote_src: true + become: yes + - name: "Move {{helm_version}} bin to /usr/local/bin and set as executable" + command: "mv /tmp/linux-amd64/helm /usr/local/bin/helm" + become: yes + - name: "Check Helm {{helm_version}}" + command: "which helm" + + - name: "Install Helm 3.3 {{helm3_3_version}}" + block: + - name: "Create directory /tmp/helm3_3" + file: + path: /tmp/helm3_3 + state: directory + - name: "Fetch tar.gz for Helm 3.3" + get_url: + url: "https://get.helm.sh/helm-v{{helm3_3_version}}-linux-amd64.tar.gz" + dest: /tmp/helm3_3 + - name: "Unarchive Helm 3.3" + unarchive: + src: "/tmp/helm3_3/helm-v{{helm3_3_version}}-linux-amd64.tar.gz" + dest: /tmp/helm3_3 + remote_src: true + become: yes + - name: "Move Helm 3.3 bin to /usr/local/bin and set as executable" + command: "mv /tmp/helm3_3/linux-amd64/helm /usr/local/bin/helm3.3" + become: yes + - name: "Check Helm 3.3" + command: "which helm3.3" + - name: "Check kubectl {{kubectl_version}}" + command: "which kubectl" + + - name: "Install Helm 3.3" + shell: | + echo "----> Installing helm 3.3" + wget 'https://get.helm.sh/helm-v{{helm3_3_version}}-linux-amd64.tar.gz' + tar -xvf 'https://get.helm.sh/helm-v{{helm3_3_version}}-linux-amd64.tar.gz' + mv linux-amd64/helm /usr/local/bin/helm3.3 + which helm3.3 + become: true + + - name: "Install Helm3.5 {{helm3_5_version}}" + block: + - name: "Create directory /tmp/helm3.5" + file: + path: /tmp/helm3.5 + state: directory + - name: "Fetch tar.gz for Helm 3.5" + get_url: + url: "https://get.helm.sh/helm-v{{helm3_5_version}}-linux-amd64.tar.gz" + dest: /tmp/helm3.5 + - name: "Unarchive Helm 3.5" + unarchive: + src: "/tmp/helm3.5/helm-v{{helm3_5_version}}-linux-amd64.tar.gz" + dest: /tmp/helm3.5 + remote_src: true + become: yes + - name: "Move Helm 3.5 bin to /usr/local/bin and set as executable" + command: "mv /tmp/helm3.5/linux-amd64/helm /usr/local/bin/helm3.5" + become: yes + - name: "Check Helm 3.5" + command: "which helm3.5" + - name: "Check kubectl {{kubectl_version}}" + command: "which kubectl" + + - name: "Install Helm 3.5" + shell: | + echo "----> Installing helm3.5" + wget 'https://get.helm.sh/helm-v{{helm3_5_version}}-linux-amd64.tar.gz' + tar -xvf 'https://get.helm.sh/helm-v{{helm3_5_version}}-linux-amd64.tar.gz' + mv linux-amd64/helm /usr/local/bin/helm3.5 + which helm3.5 + become: true + + - name: "Install ChartMuseum {{chartmuseum_version}}" + block: + - name: "Fetch bin for ChartMuseum" + get_url: + url: "https://s3.amazonaws.com/chartmuseum/release/v{{ chartmuseum_version }}/bin/linux/amd64/chartmuseum" + dest: /usr/local/bin/chartmuseum + mode: "0755" + become: yes + - name: "Check ChartMuseum {{chartmuseum_version}}" + command: "which chartmuseum" diff --git a/packer/templates/helm.json b/packer/templates/helm.json new file mode 100644 index 000000000..cd5ebaa9b --- /dev/null +++ b/packer/templates/helm.json @@ -0,0 +1,61 @@ +{ + "variables": { + "ansible_roles_path": ".galaxy", + "base_image": null, + "distro": null, + "cloud_auth_url": null, + "cloud_user": null, + "cloud_pass": null, + "cloud_network": null, + "cloud_tenant": null, + "cloud_user_data": null, + "ssh_user": null, + "ssh_proxy_host": "" + }, + "builders": [ + { + "name": "openstack", + "image_name": "ZZCI - {{user `distro`}} - helm - {{user `arch`}} - {{isotime \"20060102-150405.000\"}}", + "instance_name": "{{user `distro`}}-builder-{{uuid}}", + "source_image_name": "{{user `base_image`}}", + "type": "openstack", + "identity_endpoint": "{{user `cloud_auth_url`}}", + "username": "{{user `cloud_user`}}", + "password": "{{user `cloud_pass`}}", + "tenant_name": "{{user `cloud_tenant`}}", + "domain_name": "Default", + "region": "ca-ymq-1", + "availability_zone": "ca-ymq-2", + "networks": ["{{user `cloud_network`}}"], + "user_data_file": "{{user `cloud_user_data`}}", + "ssh_username": "{{user `ssh_user`}}", + "ssh_proxy_host": "{{user `ssh_proxy_host`}}", + "flavor": "v1-standard-1", + "metadata": { + "ci_managed": "yes" + } + } + ], + "provisioners": [ + { + "type": "shell", + "scripts": ["common-packer/provision/install-python.sh"], + "execute_command": "chmod +x {{ .Path }}; if [ \"$UID\" == \"0\" ]; then {{ .Vars }} '{{ .Path }}'; else {{ .Vars }} sudo -E '{{ .Path }}'; fi" + }, + { + "type": "shell-local", + "command": "./common-packer/ansible-galaxy.sh {{user `ansible_roles_path`}}" + }, + { + "type": "ansible", + "playbook_file": "provision/helm.yaml", + "ansible_env_vars": [ + "ANSIBLE_NOCOWS=1", + "ANSIBLE_PIPELINING=True", + "ANSIBLE_ROLES_PATH={{user `ansible_roles_path`}}", + "ANSIBLE_CALLBACK_WHITELIST=profile_tasks", + "ANSIBLE_STDOUT_CALLBACK=debug" + ] + } + ] +} -- 2.36.6