Skip to content

Commit

Permalink
Merge pull request #10 from cmurphy/chart
Browse files Browse the repository at this point in the history
Add AKS chart and CI
  • Loading branch information
cmurphy committed May 17, 2021
2 parents e1ac1b5 + 8cefd19 commit b8b41ac
Show file tree
Hide file tree
Showing 17 changed files with 193 additions and 4 deletions.
38 changes: 38 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
11 changes: 11 additions & 0 deletions charts/aks-operator-crd/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
18 changes: 18 additions & 0 deletions charts/aks-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions charts/aks-operator/questions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rancher_min_version: 2.6.0-rc1
4 changes: 4 additions & 0 deletions charts/aks-operator/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
You have deployed the Rancher AKS operator
Version: {{ .Chart.AppVersion }}
Description: This operator provisions AKS clusters
from AKSClusterConfig CRs.
9 changes: 9 additions & 0 deletions charts/aks-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{/* vim: set filetype=mustache: */}}

{{- define "system_default_registry" -}}
{{- if .Values.global.systemDefaultRegistry -}}
{{- printf "%s/" .Values.global.systemDefaultRegistry -}}
{{- else -}}
{{- "" -}}
{{- end -}}
{{- end -}}
15 changes: 15 additions & 0 deletions charts/aks-operator/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -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']
13 changes: 13 additions & 0 deletions charts/aks-operator/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions charts/aks-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
5 changes: 5 additions & 0 deletions charts/aks-operator/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: cattle-system
name: aks-operator
11 changes: 11 additions & 0 deletions charts/aks-operator/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
global:
systemDefaultRegistry: ""

aksOperator:
image:
repository: rancher/aks-operator
tag: v0.0.0

httpProxy: ""
httpsProxy: ""
noProxy: ""
4 changes: 2 additions & 2 deletions pkg/codegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ for i in bin/aks-operator-*; do
done

build-image aks-operator

./scripts/package-helm
30 changes: 30 additions & 0 deletions scripts/package-helm
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion scripts/version
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b8b41ac

Please sign in to comment.