diff --git a/charts/fastly-controller/.helmignore b/charts/fastly-controller/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/fastly-controller/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/fastly-controller/Chart.yaml b/charts/fastly-controller/Chart.yaml new file mode 100644 index 0000000..98e4767 --- /dev/null +++ b/charts/fastly-controller/Chart.yaml @@ -0,0 +1,20 @@ +apiVersion: v2 +name: fastly-controller +description: + A Helm chart for Kubernetes which installs the Fastly Controller + (https://github.com/amazeeio/fastly-controller). +home: https://github.com/amazeeio/charts +icon: https://raw.githubusercontent.com/amazeeio/charts/main/icon.png +maintainers: +- name: shreddedbacon + email: ben.jackson@amazee.io + url: https://amazee.io +- name: smlx + email: scott.leggett@amazee.io + url: https://amazee.io + +type: application + +version: 0.1.0 + +appVersion: v0.0.1 diff --git a/charts/fastly-controller/README.md b/charts/fastly-controller/README.md new file mode 100644 index 0000000..acbfe5c --- /dev/null +++ b/charts/fastly-controller/README.md @@ -0,0 +1,3 @@ +# Fastly Controller Helm Chart + +This chart installs the [Fastly Controller](https://github.com/amazeeio/fastly-controller). diff --git a/charts/fastly-controller/ci/linter-values.yaml b/charts/fastly-controller/ci/linter-values.yaml new file mode 100644 index 0000000..a8f4b4d --- /dev/null +++ b/charts/fastly-controller/ci/linter-values.yaml @@ -0,0 +1,4 @@ +fastly: + apiToken: 'a8ebfff7e54ebc786' + tlsConfigID: '42cd671d142d18bba26' + clusterName: 'region1' diff --git a/charts/fastly-controller/templates/NOTES.txt b/charts/fastly-controller/templates/NOTES.txt new file mode 100644 index 0000000..ec6b46f --- /dev/null +++ b/charts/fastly-controller/templates/NOTES.txt @@ -0,0 +1 @@ +Fastly controller has been installed. diff --git a/charts/fastly-controller/templates/_helpers.tpl b/charts/fastly-controller/templates/_helpers.tpl new file mode 100644 index 0000000..7f590b4 --- /dev/null +++ b/charts/fastly-controller/templates/_helpers.tpl @@ -0,0 +1,59 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "fastly-controller.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 the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "fastly-controller.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 "fastly-controller.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "fastly-controller.labels" -}} +helm.sh/chart: {{ include "fastly-controller.chart" . }} +{{ include "fastly-controller.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "fastly-controller.selectorLabels" -}} +app.kubernetes.io/name: {{ include "fastly-controller.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "fastly-controller.serviceAccountName" -}} +{{ default "fastly-controller" .Values.serviceAccount.nameOverride }} +{{- end }} diff --git a/charts/fastly-controller/templates/clusterrole.yaml b/charts/fastly-controller/templates/clusterrole.yaml new file mode 100644 index 0000000..983f688 --- /dev/null +++ b/charts/fastly-controller/templates/clusterrole.yaml @@ -0,0 +1,67 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "fastly-controller.fullname" . }}-manager + labels: + {{- include "fastly-controller.labels" . | nindent 4 }} +rules: +- apiGroups: + - '*' + resources: + - ingress + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - '*' + resources: + - ingress/status + verbs: + - get + - patch + - update +- apiGroups: + - '*' + resources: + - ingresses + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - '*' + resources: + - secrets + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "fastly-controller.fullname" . }}-proxy + labels: + {{- include "fastly-controller.labels" . | nindent 4 }} +rules: +- apiGroups: + - authentication.k8s.io + resources: + - tokenreviews + verbs: + - create +- apiGroups: + - authorization.k8s.io + resources: + - subjectaccessreviews + verbs: + - create diff --git a/charts/fastly-controller/templates/clusterrolebinding.yaml b/charts/fastly-controller/templates/clusterrolebinding.yaml new file mode 100644 index 0000000..1dc81c1 --- /dev/null +++ b/charts/fastly-controller/templates/clusterrolebinding.yaml @@ -0,0 +1,29 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "fastly-controller.fullname" . }}-manager + labels: + {{- include "fastly-controller.labels" . | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "fastly-controller.fullname" . }}-manager +subjects: +- kind: ServiceAccount + name: {{ include "fastly-controller.serviceAccountName" . }} + namespace: {{ .Release.Namespace | quote }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "fastly-controller.fullname" . }}-proxy + labels: + {{- include "fastly-controller.labels" . | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "fastly-controller.fullname" . }}-proxy +subjects: +- kind: ServiceAccount + name: {{ include "fastly-controller.serviceAccountName" . }} + namespace: {{ .Release.Namespace | quote }} diff --git a/charts/fastly-controller/templates/deployment.yaml b/charts/fastly-controller/templates/deployment.yaml new file mode 100644 index 0000000..18cc939 --- /dev/null +++ b/charts/fastly-controller/templates/deployment.yaml @@ -0,0 +1,70 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "fastly-controller.fullname" . }} + labels: + {{- include "fastly-controller.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "fastly-controller.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "fastly-controller.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "fastly-controller.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: kube-rbac-proxy + securityContext: + {{- toYaml .Values.kubeRBACProxy.securityContext | nindent 10 }} + image: "{{ .Values.kubeRBACProxy.image.repository }}:{{ .Values.kubeRBACProxy.image.tag }}" + imagePullPolicy: {{ .Values.kubeRBACProxy.image.pullPolicy }} + args: + - "--secure-listen-address=0.0.0.0:8443" + - "--upstream=http://127.0.0.1:8080/" + - "--logtostderr=true" + - "--v=10" + ports: + - containerPort: 8443 + name: https + resources: + {{- toYaml .Values.kubeRBACProxy.resources | nindent 10 }} + - name: manager + securityContext: + {{- toYaml .Values.securityContext | nindent 10 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion}}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: FASTLY_API_TOKEN + value: {{ .Values.fastly.apiToken }} + - name: FASTLY_PLATFORM_TLS_CONFIGURATION_ID + value: {{ .Values.fastly.tlsConfigID }} + - name: CLUSTER_NAME + value: {{ .Values.fastly.clusterName }} + command: + - /manager + {{- with .Values.extraArgs }} + args: + {{- toYaml . | nindent 8 }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 10 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/fastly-controller/templates/role.yaml b/charts/fastly-controller/templates/role.yaml new file mode 100644 index 0000000..bebd2d8 --- /dev/null +++ b/charts/fastly-controller/templates/role.yaml @@ -0,0 +1,33 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ include "fastly-controller.fullname" . }}-leader-election + labels: + {{- include "fastly-controller.labels" . | nindent 4 }} +rules: +- apiGroups: + - "" + resources: + - configmaps + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - "" + resources: + - configmaps/status + verbs: + - get + - update + - patch +- apiGroups: + - "" + resources: + - events + verbs: + - create diff --git a/charts/fastly-controller/templates/rolebinding.yaml b/charts/fastly-controller/templates/rolebinding.yaml new file mode 100644 index 0000000..259b066 --- /dev/null +++ b/charts/fastly-controller/templates/rolebinding.yaml @@ -0,0 +1,14 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ include "fastly-controller.fullname" . }}-leader-election + labels: + {{- include "fastly-controller.labels" . | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ include "fastly-controller.fullname" . }}-leader-election +subjects: +- kind: ServiceAccount + name: {{ include "fastly-controller.serviceAccountName" . }} + namespace: {{ .Release.Namespace | quote }} diff --git a/charts/fastly-controller/templates/service.yaml b/charts/fastly-controller/templates/service.yaml new file mode 100644 index 0000000..0a77c10 --- /dev/null +++ b/charts/fastly-controller/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "fastly-controller.fullname" . }} + labels: + {{- include "fastly-controller.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - name: https + port: {{ .Values.service.port }} + targetPort: https + protocol: TCP + selector: + {{- include "fastly-controller.selectorLabels" . | nindent 4 }} diff --git a/charts/fastly-controller/templates/serviceaccount.yaml b/charts/fastly-controller/templates/serviceaccount.yaml new file mode 100644 index 0000000..46c244e --- /dev/null +++ b/charts/fastly-controller/templates/serviceaccount.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "fastly-controller.serviceAccountName" . }} + labels: + {{- include "fastly-controller.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} diff --git a/charts/fastly-controller/values.yaml b/charts/fastly-controller/values.yaml new file mode 100644 index 0000000..e38b2a4 --- /dev/null +++ b/charts/fastly-controller/values.yaml @@ -0,0 +1,53 @@ +fastly: + apiToken: "" + tlsConfigID: "" + clusterName: "" + +extraArgs: +- "--metrics-addr=127.0.0.1:8080" +- "--enable-leader-election=true" + +image: + repository: amazeeio/fastly-controller + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" + +serviceAccount: + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + +securityContext: {} + +service: + type: ClusterIP + port: 8443 + +resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +# this sidecar runs in the same pod as fastly-controller +kubeRBACProxy: + image: + repository: gcr.io/kubebuilder/kube-rbac-proxy + pullPolicy: IfNotPresent + tag: v0.4.1 + + securityContext: {} + + resources: {}