Skip to content

Commit

Permalink
Created a minimal Helm Chart (#175)
Browse files Browse the repository at this point in the history
* Implemented a minimal helm chart with release automation using Github
Pages

* Removed stray files

* Updated chart
  • Loading branch information
ellistarn authored Dec 3, 2020
1 parent 048aa7a commit 6446788
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 46 deletions.
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
GOFLAGS ?= "-tags=${CLOUD_PROVIDER}"

RELEASE_REPO ?= public.ecr.aws/b6u6q9h4
RELEASE_VERSION ?= v0.1.1
RELEASE_MANIFEST = releases/${CLOUD_PROVIDER}/manifest.yaml

WITH_GOFLAGS = GOFLAGS=${GOFLAGS}
WITH_RELEASE_REPO = KO_DOCKER_REPO=${RELEASE_REPO}

help: ## Display help
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

all: generate verify test ## Run all steps in the developer loop
dev: codegen verify test ## Run all steps in the developer loop

ci: codegen verify battletest ## Run all steps used by continuous integration

ci: generate verify battletest ## Run all steps used by continuous integration
release: publish helm docs ## Run all steps in release workflow

test: ## Run tests
ginkgo -r
Expand All @@ -31,7 +35,7 @@ verify: ## Verify code. Includes dependencies, linting, formatting, etc
go fmt ./...
golangci-lint run

generate: ## Generate code. Must be run if changes are made to ./pkg/apis/...
codegen: ## Generate code. Must be run if changes are made to ./pkg/apis/...
controller-gen \
object:headerFile="hack/boilerplate.go.txt" \
webhook \
Expand All @@ -57,10 +61,13 @@ apply: ## Deploy the controller into your ~/.kube/config cluster
delete: ## Delete the controller from your ~/.kube/config cluster
kubectl kustomize config | ko delete -f -

release: ## Publish a versioned container image to $KO_DOCKER_REPO/karpenter and generate release manifests.
kubectl kustomize config \
| $(WITH_RELEASE_REPO) $(WITH_GOFLAGS) ko resolve -B -t $(RELEASE_VERSION) -f - \
> releases/${CLOUD_PROVIDER}/$(RELEASE_VERSION).yaml
publish: ## Generate release manifests and publish a versioned container image.
kubectl kustomize config | $(WITH_RELEASE_REPO) $(WITH_GOFLAGS) ko resolve -B -t $(RELEASE_VERSION) -f - > $(RELEASE_MANIFEST)

helm: ## Generate Helm Chart
cp $(RELEASE_MANIFEST) charts/karpenter/templates
yq w -i charts/karpenter/Chart.yaml version $(RELEASE_VERSION)
cd charts; helm package karpenter; helm repo index .

docs: ## Generate Docs
gen-crd-api-reference-docs \
Expand All @@ -72,4 +79,4 @@ docs: ## Generate Docs
toolchain: ## Install developer toolchain
./hack/toolchain.sh

.PHONY: help all ci test release run apply delete verify generate docs toolchain
.PHONY: help dev ci release test battletest verify codegen apply delete publish helm docs toolchain
13 changes: 13 additions & 0 deletions charts/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
entries:
karpenter:
- apiVersion: v2
created: "2020-12-02T16:39:58.069275-08:00"
description: A Helm chart for https://github.com/awslabs/karpenter/.
digest: 39685c8cbe9a757ca48721aed08b49111fef18bc2a9f67d3223f19d0706f09f7
name: karpenter
type: application
urls:
- karpenter-v0.1.1.tgz
version: v0.1.1
generated: "2020-12-02T16:39:58.06806-08:00"
Binary file added charts/karpenter-v0.1.1.tgz
Binary file not shown.
9 changes: 9 additions & 0 deletions charts/karpenter/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: cert-manager
repository: https://charts.jetstack.io
version: v1.1.0
- name: kube-prometheus-stack
repository: https://prometheus-community.github.io/helm-charts
version: 12.3.0
digest: sha256:5595919ac269b4105dd65d20eb27cb271b8976c1d10903e0b504d349df30f017
generated: "2020-12-02T11:48:25.741819-08:00"
5 changes: 5 additions & 0 deletions charts/karpenter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: karpenter
description: A Helm chart for https://github.com/awslabs/karpenter/.
type: application
version: v0.1.1
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ spec:
defaultMode: 420
secretName: webhook-server-cert
---
apiVersion: cert-manager.io/v1alpha2
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
labels:
Expand All @@ -965,7 +965,7 @@ spec:
name: karpenter-selfsigned-issuer
secretName: webhook-server-cert
---
apiVersion: cert-manager.io/v1alpha2
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
labels:
Expand Down
4 changes: 2 additions & 2 deletions config/webhook/certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# More document can be found at https://docs.cert-manager.io
# WARNING: Targets CertManager 0.11 check https://docs.cert-manager.io/en/latest/tasks/upgrading/index.html for
# breaking changes
apiVersion: cert-manager.io/v1alpha2
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: selfsigned-issuer
namespace: karpenter
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1alpha2
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
Expand Down
4 changes: 2 additions & 2 deletions config/webhook/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ vars:
objref:
kind: Certificate
group: cert-manager.io
version: v1alpha2
version: v1
name: serving-cert # this name should match the one in certificate.yaml
fieldref:
fieldpath: metadata.namespace
- name: CERTIFICATE_NAME
objref:
kind: Certificate
group: cert-manager.io
version: v1alpha2
version: v1
name: serving-cert # this name should match the one in certificate.yaml
- name: SERVICE_NAMESPACE # namespace of the service
objref:
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1622,5 +1622,5 @@ map[string]string
<hr/>
<p><em>
Generated with <code>gen-crd-api-reference-docs</code>
on git commit <code>e85ad5d</code>.
on git commit <code>52b7290</code>.
</em></p>
41 changes: 13 additions & 28 deletions hack/quick-install.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#!/bin/bash
set -eu -o pipefail

TEMP_DIR=$(mktemp -d)
trap "rm -rf $TEMP_DIR" EXIT

main() {
local command=${1:-'--apply'}
if [[ $command = "--usage" ]]; then
usage
elif [[ $command = "--apply" ]]; then
if [[ $command = "--apply" ]]; then
apply
echo "Installation complete!"
elif [[ $command = "--delete" ]]; then
Expand All @@ -25,49 +20,36 @@ usage() {
cat <<EOF
######################## USAGE ########################
hack/quick-install.sh # Defaults to apply
hack/quick-install.sh --usage # Displays usage
hack/quick-install.sh --apply # Creates all resources
hack/quick-install.sh --delete # Deletes all resources
#######################################################
EOF
}

delete() {
make delete || true
helm uninstall cert-manager --namespace cert-manager || true
helm uninstall kube-prometheus-stack --namespace monitoring || true
helm delete cert-manager --namespace cert-manager || true
helm delete kube-prometheus-stack --namespace monitoring || true
helm delete karpenter || true

kubectl delete namespace cert-manager monitoring || true
}

# If this fails you may have an old installation hanging around.
# `helm list -A`
# `helm delete <OLD_INSTALLATION>`
apply() {
helm repo add jetstack https://charts.jetstack.io
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add karpenter https://awslabs.github.io/karpenter/charts
helm repo update

certmanager
prometheus
make apply
}

# If this fails you may have an old installation hanging around. If it's just for
# testing, you can remove it with something like this (match the version to the version
# you installed).
#
# VERSION=$(kubectl get deployment cert-manager -n cert-manager -ojsonpath='{.spec.template.spec.containers[0].image}{"\n"}' | cut -f2 -d:)
# kubectl delete -f https://github.com/jetstack/cert-manager/releases/download/${VERSION}/cert-manager.yaml
certmanager() {
helm upgrade --install cert-manager jetstack/cert-manager \
--atomic \
--create-namespace \
--namespace cert-manager \
--version v1.0.0 \
--version v1.1.0 \
--set installCRDs=true
}

prometheus() {
# Minimal install of prometheus operator.
helm upgrade --install kube-prometheus-stack prometheus-community/kube-prometheus-stack \
--atomic \
--create-namespace \
--namespace monitoring \
--version 9.4.5 \
Expand All @@ -84,6 +66,9 @@ prometheus() {
--set kubeStateMetrics.enabled=false \
--set nodeExporter.enabled=false \
--set prometheus.enabled=false

helm upgrade --install karpenter charts/karpenter
}

usage
main "$@"
6 changes: 3 additions & 3 deletions releases/aws/v0.1.0.yaml → releases/aws/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ spec:
control-plane: karpenter
spec:
containers:
- image: public.ecr.aws/b6u6q9h4/karpenter:v0.1.0@sha256:3382343767e6f98bf6cfc2ba45b361597ec58f27169959d35cb36016e43e9c2e
- image: public.ecr.aws/b6u6q9h4/controller:v0.1.1@sha256:6a5c82cb34bbd6f714145cdfe7c14ac28404a00b56eec9b746ac61eeb3a6d6a8
name: manager
ports:
- containerPort: 9443
Expand All @@ -949,7 +949,7 @@ spec:
defaultMode: 420
secretName: webhook-server-cert
---
apiVersion: cert-manager.io/v1alpha2
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
labels:
Expand All @@ -965,7 +965,7 @@ spec:
name: karpenter-selfsigned-issuer
secretName: webhook-server-cert
---
apiVersion: cert-manager.io/v1alpha2
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
labels:
Expand Down

0 comments on commit 6446788

Please sign in to comment.