Skip to content

Commit

Permalink
Add helm chart kore.0.0.1
Browse files Browse the repository at this point in the history
- Add chart build to CI script

Closes kedacore#23
  • Loading branch information
ahmelsayed committed Mar 8, 2019
1 parent d78533a commit 1eba8eb
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 5 deletions.
8 changes: 6 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ version: 2
jobs:
build:
docker:
- image: circleci/golang:1.10
- image: projectkore.azurecr.io/build-tools:latest
auth:
username: $ACR_USERNAME
password: $ACR_PASSWORD
working_directory: /go/src/github.com/Azure/Kore
steps:
- checkout
- setup_remote_docker
- run: docker login -u "${ACR_USERNAME}" -p "${ACR_PASSWORD}" ${ACR_REGISTRY}
- run: make test
- run: make ci-build-all
- run: make ci-build-all
- run: make publish-edge-chart
24 changes: 21 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ CGO?=0
TARGET_OS?=linux

##################################################
# Docker variables #
# Variables #
##################################################

BASE_IMAGE_NAME := kore
IMAGE_NAMESPACE := project-kore
IMAGE_TAG := $(CIRCLE_BRANCH)
IMAGE_NAME := $(ACR_REGISTRY)/$(BASE_IMAGE_NAME):$(IMAGE_TAG)

IMAGE_NAME := $(ACR_REGISTRY)/$(IMAGE_NAMESPACE)/$(BASE_IMAGE_NAME):$(IMAGE_TAG)
GIT_VERSION = $(shell git describe --always --abbrev=7)
DATE = $(shell date -u +"%Y.%m.%d.%H.%M.%S")

##################################################
# Tests #
Expand Down Expand Up @@ -41,3 +42,20 @@ build-container: build
push-container: build-container
docker push $(IMAGE_NAME)


##################################################
# Helm Chart tasks #
##################################################
.PHONY: publish-edge-chart
publish-edge-chart:
rm -rf /tmp/kore-edge
cp -r -L chart/kore /tmp/kore-edge
sed -i "s/^name:.*/name: kore-edge/g" /tmp/kore-edge/Chart.yaml
sed -i "s/^version:.*/version: 0.0.1-$(DATE)-$(GIT_VERSION)/g" /tmp/kore-edge/Chart.yaml
sed -i "s/^appVersion:.*/appVersion: $(GIT_VERSION)/g" /tmp/kore-edge/Chart.yaml
sed -i "s/^ tag:.*/ tag: master/g" /tmp/kore-edge/values.yaml

helm lint /tmp/kore-edge/
helm package /tmp/kore-edge/
az login --service-principal -u '$(AZURE_SP_ID)' -p '$(AZURE_SP_KEY)' --tenant '$(AZURE_SP_TENANT)'
az acr helm push -n projectkore kore-edge-0.0.1-$(DATE)-$(GIT_VERSION).tgz
22 changes: 22 additions & 0 deletions chart/kore/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
11 changes: 11 additions & 0 deletions chart/kore/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
name: kore
description: Event based autoscaler for Azure Functions deployments on Kubernetes
version: 0.0.1
appVersion: 0.0.1
home: https://github.com/Azure/Kore
sources:
- https://github.com/Azure/Kore
maintainers:
- name: Ahmed ElSayed
email: [email protected]
Empty file added chart/kore/templates/NOTES.txt
Empty file.
54 changes: 54 additions & 0 deletions chart/kore/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{/* https://github.com/helm/charts/blob/master/stable/kubernetes-dashboard/templates/_helpers.tpl */}}

{{/*
Expand the name of the chart.
*/}}
{{- define "kore.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by DNS naming spec).
If release name contains chart name it will be used as a full name
*/}}
{{- define "kore.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "kore.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "kore.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{default (include "kore.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Shared labels
*/}}
{{- define "kore.labels" -}}
app: {{ template "kore.name" . }}
chart: {{ template "kore.chart" . }}
release: {{ .Release.Name }}
date: {{ now | htmlDate }}
{{- end -}}
17 changes: 17 additions & 0 deletions chart/kore/templates/clsuter-role-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
{{- include "kore.labels" . | nindent 4 }}
name: {{ template "kore.fullname" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: {{ template "kore.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end -}}
26 changes: 26 additions & 0 deletions chart/kore/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
{{- include "kore.labels" . | nindent 4 }}
name: {{ template "kore.fullname" . }}
namespace: {{ .Release.Namespace }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
name: {{ template "kore.fullname" . }}
instance: {{ template "kore.fullname" . }}-instance
template:
metadata:
labels:
name: {{ template "kore.fullname" . }}
instance: {{ template "kore.fullname" . }}-instance
spec:
serviceAccountName: {{ template "kore.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
imagePullSecrets:
- name: {{ template "kore.fullname" . }}-docker-auth
10 changes: 10 additions & 0 deletions chart/kore/templates/docker-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
data:
.dockerconfigjson: eyJhdXRocyI6eyJwcm9qZWN0a29yZS5henVyZWNyLmlvIjp7InVzZXJuYW1lIjoiYjUxNGI2MGMtNjhjYy00ZjEyLWIzNjEtMzg1ODg3OGIyNDc5IiwicGFzc3dvcmQiOiI0alg1dmtQVFNyVVE5NlVCYlUvQjdDUXJCb0p3VDYyV1NzNVdmWnRGYkI4PSIsImF1dGgiOiJZalV4TkdJMk1HTXROamhqWXkwMFpqRXlMV0l6TmpFdE16ZzFPRGczT0dJeU5EYzVPalJxV0RWMmExQlVVM0pWVVRrMlZVSmlWUzlDTjBOUmNrSnZTbmRVTmpKWFUzTTFWMlphZEVaaVFqZzkifX19
kind: Secret
metadata:
labels:
{{- include "kore.labels" . | nindent 4 }}
name: {{ template "kore.fullname" . }}-docker-auth
namespace: {{ .Release.Namespace }}
type: kubernetes.io/dockerconfigjson
13 changes: 13 additions & 0 deletions chart/kore/templates/scaledobject-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: scaledobjects.kore.k8s.io
annotations:
"helm.sh/hook": crd-install
spec:
group: kore.k8s.io
version: v1alpha1
names:
kind: ScaledObject
plural: scaledobjects
scope: Namespaced
9 changes: 9 additions & 0 deletions chart/kore/templates/service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
{{- include "kore.labels" . | nindent 4 }}
name: {{ template "kore.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end -}}
16 changes: 16 additions & 0 deletions chart/kore/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
nameOverride:
fullnameOverride:

image:
repository: projectkore.azurecr.io/kore
tag: master
pullPolicy: Always

replicaCount: 1

rbac:
create: true

serviceAccount:
create: true
name: kore-service-account
44 changes: 44 additions & 0 deletions tools/build-tools.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM ubuntu:18.04

# Install prerequisite
RUN apt-get update && \
apt-get install -y wget curl build-essential git

# Install azure-cli
RUN apt-get install apt-transport-https lsb-release software-properties-common dirmngr -y && \
AZ_REPO=$(lsb_release -cs) && \
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | \
tee /etc/apt/sources.list.d/azure-cli.list && \
apt-key --keyring /etc/apt/trusted.gpg.d/Microsoft.gpg adv \
--keyserver packages.microsoft.com \
--recv-keys BC528686B50D79E339D3721CEB3E94ADBE1229CF && \
apt-get update && \
apt-get install -y azure-cli

# Install docker client
RUN wget https://download.docker.com/linux/static/stable/x86_64/docker-18.09.3.tgz && \
docker_sha256=8b886106cfc362f1043debfe178c35b6f73ec42380b034a3919a235fe331e053 && \
echo "$docker_sha256 docker-18.09.3.tgz" | sha256sum -c - && \
tar xvzf docker-18.09.3.tgz && \
mv docker/* /usr/local/bin && \
rm -rf docker docker-18.09.3.tgz

# Install golang
RUN wget https://dl.google.com/go/go1.12.linux-amd64.tar.gz && \
go_sha256=750a07fef8579ae4839458701f4df690e0b20b8bcce33b437e4df89c451b6f13 && \
echo "$go_sha256 go1.12.linux-amd64.tar.gz" | sha256sum -c - && \
tar -C /usr/local -xvzf go1.12.linux-amd64.tar.gz && \
rm -rf go1.12.linux-amd64.tar.gz

# Install helm/tiller
RUN wget https://storage.googleapis.com/kubernetes-helm/helm-v2.13.0-linux-amd64.tar.gz && \
helm_sha256=15eca6ad225a8279de80c7ced42305e24bc5ac60bb7d96f2d2fa4af86e02c794 && \
echo "$helm_sha256 helm-v2.13.0-linux-amd64.tar.gz" | sha256sum -c - && \
tar xzvf helm-v2.13.0-linux-amd64.tar.gz && \
mv linux-amd64/helm /usr/local/bin && mv linux-amd64/tiller /usr/local/bin && \
rm -rf linux-amd64 helm-v2.13.0-linux-amd64.tar.gz && \
helm init --client-only

ENV PATH=${PATH}:/usr/local/go/bin \
GOROOT=/usr/local/go \
GOPATH=/go

0 comments on commit 1eba8eb

Please sign in to comment.