diff --git a/.drone.yml b/.drone.yml index ebf3f7ee..8d282216 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,6 +20,25 @@ steps: - pull_request - tag +- name: github_binary_release + image: plugins/github-release + settings: + api_key: + from_secret: github_token + prerelease: true + checksum: + - sha256 + checksum_file: CHECKSUMsum-amd64.txt + checksum_flatten: true + files: + - "dist/artifacts/*" + when: + ref: + - refs/head/master + - refs/tags/* + event: + - tag + - name: docker-publish image: plugins/docker settings: @@ -62,6 +81,25 @@ steps: - pull_request - tag +- name: github_binary_release + image: plugins/github-release + settings: + api_key: + from_secret: github_token + prerelease: true + checksum: + - sha256 + checksum_file: CHECKSUMsum-arm64.txt + checksum_flatten: true + files: + - "dist/artifacts/*" + when: + ref: + - refs/head/master + - refs/tags/* + event: + - tag + - name: docker-publish image: plugins/docker settings: diff --git a/Dockerfile.dapper b/Dockerfile.dapper index ffcffd07..bd6d8a3d 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -6,8 +6,9 @@ ENV ARCH $DAPPER_HOST_ARCH RUN apt update && \ apt install -y bash git gcc docker.io vim less file curl wget ca-certificates RUN if [ "${ARCH}" = "amd64" ]; then \ - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.30.0; \ + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.30.0; \ fi +RUN curl -sL https://get.helm.sh/helm-v3.3.0-linux-${ARCH}.tar.gz | tar xvzf - -C /usr/local/bin --strip-components=1 ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS ENV DAPPER_SOURCE /go/src/github.com/rancher/aks-operator/ diff --git a/charts/aks-operator-crd/Chart.yaml b/charts/aks-operator-crd/Chart.yaml new file mode 100644 index 00000000..73227dbb --- /dev/null +++ b/charts/aks-operator-crd/Chart.yaml @@ -0,0 +1,11 @@ +apiVersion: v2 +name: rancher-aks-operator-crd +description: AKS Operator CustomResourceDefinitions +version: 999 +appVersion: 999 +annotations: + catalog.cattle.io/certified: rancher + catalog.cattle.io/namespace: cattle-system + catalog.cattle.io/hidden: "true" + catalog.cattle.io/release-name: rancher-aks-operator-crd + catalog.cattle.io/os: linux diff --git a/crds/aksclusterconfig.yaml b/charts/aks-operator-crd/templates/crds.yaml similarity index 100% rename from crds/aksclusterconfig.yaml rename to charts/aks-operator-crd/templates/crds.yaml diff --git a/charts/aks-operator/Chart.yaml b/charts/aks-operator/Chart.yaml new file mode 100644 index 00000000..031cba5b --- /dev/null +++ b/charts/aks-operator/Chart.yaml @@ -0,0 +1,18 @@ +apiVersion: v2 +name: rancher-aks-operator +description: A Helm chart for provisioning AKS clusters +home: https://github.com/rancher/aks-operator +sources: + - "https://github.com/rancher/aks-operator" +version: 999 +appVersion: 999 +annotations: + catalog.cattle.io/auto-install: rancher-aks-operator-crd=match + catalog.cattle.io/certified: rancher + catalog.cattle.io/hidden: "true" + catalog.cattle.io/scope: management + catalog.cattle.io/namespace: cattle-system + catalog.cattle.io/release-name: rancher-aks-operator + catalog.cattle.io/provides-gvr: aksclusterconfigs.aks.cattle.io/v1 + catalog.cattle.io/os: linux + catalog.cattle.io/rancher-version: ">= 2.6.0-alpha" diff --git a/charts/aks-operator/questions.yaml b/charts/aks-operator/questions.yaml new file mode 100644 index 00000000..d891df4a --- /dev/null +++ b/charts/aks-operator/questions.yaml @@ -0,0 +1 @@ +rancher_min_version: 2.6.0-rc1 diff --git a/charts/aks-operator/templates/NOTES.txt b/charts/aks-operator/templates/NOTES.txt new file mode 100644 index 00000000..5ba05b48 --- /dev/null +++ b/charts/aks-operator/templates/NOTES.txt @@ -0,0 +1,4 @@ +You have deployed the Rancher AKS operator +Version: {{ .Chart.AppVersion }} +Description: This operator provisions AKS clusters +from AKSClusterConfig CRs. diff --git a/charts/aks-operator/templates/_helpers.tpl b/charts/aks-operator/templates/_helpers.tpl new file mode 100644 index 00000000..be11b4a6 --- /dev/null +++ b/charts/aks-operator/templates/_helpers.tpl @@ -0,0 +1,9 @@ +{{/* vim: set filetype=mustache: */}} + +{{- define "system_default_registry" -}} +{{- if .Values.global.systemDefaultRegistry -}} +{{- printf "%s/" .Values.global.systemDefaultRegistry -}} +{{- else -}} +{{- "" -}} +{{- end -}} +{{- end -}} diff --git a/charts/aks-operator/templates/clusterrole.yaml b/charts/aks-operator/templates/clusterrole.yaml new file mode 100644 index 00000000..1bcc0ebe --- /dev/null +++ b/charts/aks-operator/templates/clusterrole.yaml @@ -0,0 +1,15 @@ +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: aks-operator + namespace: cattle-system +rules: + - apiGroups: [''] + resources: ['secrets'] + verbs: ['get', 'list', 'create', 'watch'] + - apiGroups: ['aks.cattle.io'] + resources: ['aksclusterconfigs'] + verbs: ['get', 'list', 'update', 'watch'] + - apiGroups: ['aks.cattle.io'] + resources: ['aksclusterconfigs/status'] + verbs: ['update'] diff --git a/charts/aks-operator/templates/clusterrolebinding.yaml b/charts/aks-operator/templates/clusterrolebinding.yaml new file mode 100644 index 00000000..7aa7e785 --- /dev/null +++ b/charts/aks-operator/templates/clusterrolebinding.yaml @@ -0,0 +1,13 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: aks-operator + namespace: cattle-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: aks-operator +subjects: +- kind: ServiceAccount + name: aks-operator + namespace: cattle-system diff --git a/charts/aks-operator/templates/deployment.yaml b/charts/aks-operator/templates/deployment.yaml new file mode 100644 index 00000000..83942554 --- /dev/null +++ b/charts/aks-operator/templates/deployment.yaml @@ -0,0 +1,27 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: aks-config-operator + namespace: cattle-system +spec: + replicas: 1 + selector: + matchLabels: + ke.cattle.io/operator: aks + template: + metadata: + labels: + ke.cattle.io/operator: aks + spec: + serviceAccountName: aks-operator + containers: + - name: aks-operator + image: {{ template "system_default_registry" . }}{{ .Values.aksOperator.image.repository }}:{{ .Values.aksOperator.image.tag }} + imagePullPolicy: IfNotPresent + env: + - name: HTTP_PROXY + value: {{ .Values.httpProxy }} + - name: HTTPS_PROXY + value: {{ .Values.httpsProxy }} + - name: NO_PROXY + value: {{ .Values.noProxy }} diff --git a/charts/aks-operator/templates/serviceaccount.yaml b/charts/aks-operator/templates/serviceaccount.yaml new file mode 100644 index 00000000..9c40a152 --- /dev/null +++ b/charts/aks-operator/templates/serviceaccount.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + namespace: cattle-system + name: aks-operator diff --git a/charts/aks-operator/values.yaml b/charts/aks-operator/values.yaml new file mode 100644 index 00000000..5b77f0c4 --- /dev/null +++ b/charts/aks-operator/values.yaml @@ -0,0 +1,11 @@ +global: + systemDefaultRegistry: "" + +aksOperator: + image: + repository: rancher/aks-operator + tag: v0.0.0 + +httpProxy: "" +httpsProxy: "" +noProxy: "" diff --git a/pkg/codegen/main.go b/pkg/codegen/main.go index 2180d31e..604b4f35 100644 --- a/pkg/codegen/main.go +++ b/pkg/codegen/main.go @@ -62,7 +62,7 @@ func main() { panic(err) } - if err := saveCRDYaml("aksclusterconfig", string(aksCCYaml)); err != nil { + if err := saveCRDYaml("aks-operator-crd", string(aksCCYaml)); err != nil { panic(err) } @@ -85,7 +85,7 @@ func newCRD(obj interface{}, customize func(crd.CRD) crd.CRD) crd.CRD { } func saveCRDYaml(name, yaml string) error { - filename := fmt.Sprintf("./crds/%s.yaml", name) + filename := fmt.Sprintf("./charts/%s/templates/crds.yaml", name) save, err := os.Create(filename) if err != nil { return err diff --git a/scripts/package b/scripts/package index b7a71d96..e9b692c3 100755 --- a/scripts/package +++ b/scripts/package @@ -29,3 +29,5 @@ for i in bin/aks-operator-*; do done build-image aks-operator + +./scripts/package-helm diff --git a/scripts/package-helm b/scripts/package-helm new file mode 100755 index 00000000..9c6cc375 --- /dev/null +++ b/scripts/package-helm @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +if ! hash helm 2>/dev/null; then + exit 0 +fi + +cd $(dirname $0)/.. +. ./scripts/version + +rm -rf build/charts +mkdir -p build dist/artifacts +cp -rf charts build/ + +sed -i \ + -e 's/version:.*/version: '${HELM_VERSION}'/' \ + -e 's/appVersion:.*/appVersion: '${HELM_VERSION}'/' \ + build/charts/aks-operator/Chart.yaml + +sed -i \ + -e 's/tag:.*/tag: '${HELM_TAG}'/' \ + build/charts/aks-operator/values.yaml + +sed -i \ + -e 's/version:.*/version: '${HELM_VERSION}'/' \ + -e 's/appVersion:.*/appVersion: '${HELM_VERSION}'/' \ + build/charts/aks-operator-crd/Chart.yaml + +helm package -d ./dist/artifacts ./build/charts/aks-operator +helm package -d ./dist/artifacts ./build/charts/aks-operator-crd diff --git a/scripts/version b/scripts/version index ff843b47..6aae1fd4 100644 --- a/scripts/version +++ b/scripts/version @@ -19,9 +19,13 @@ fi SUFFIX="-${ARCH}" +HELM_TAG=${TAG:-${VERSION}} +HELM_VERSION=${HELM_TAG/v/} TAG=${TAG:-${VERSION}${SUFFIX}} REPO=${REPO:-rancher} if echo $TAG | grep -q dirty; then - TAG=local-test + TAG=dev + HELM_TAG=dev + HELM_VERSION=0.0.0-dev fi