diff --git a/helm/kubeops/.helmignore b/helm/kubeops/.helmignore new file mode 100644 index 000000000..50af03172 --- /dev/null +++ b/helm/kubeops/.helmignore @@ -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/ diff --git a/helm/kubeops/Chart.yaml b/helm/kubeops/Chart.yaml new file mode 100644 index 000000000..6ae420a2f --- /dev/null +++ b/helm/kubeops/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: kubeops +version: 0.1.0 diff --git a/helm/kubeops/templates/_helpers.tpl b/helm/kubeops/templates/_helpers.tpl new file mode 100644 index 000000000..74585995d --- /dev/null +++ b/helm/kubeops/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "kubeops.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 "kubeops.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 "kubeops.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/helm/kubeops/templates/clusterrole.yaml b/helm/kubeops/templates/clusterrole.yaml new file mode 100644 index 000000000..72aa28188 --- /dev/null +++ b/helm/kubeops/templates/clusterrole.yaml @@ -0,0 +1,13 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "kubeops.fullname" . }}-clusterrole + labels: + app.kubernetes.io/name: {{ include "kubeops.name" . }} + helm.sh/chart: {{ include "kubeops.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +rules: + - apiGroups: ["*"] + resources: ["*"] + verbs: ["get", "watch", "list"] diff --git a/helm/kubeops/templates/clusterrolebinding.yaml b/helm/kubeops/templates/clusterrolebinding.yaml new file mode 100644 index 000000000..ef428e587 --- /dev/null +++ b/helm/kubeops/templates/clusterrolebinding.yaml @@ -0,0 +1,17 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "kubeops.fullname" . }}-clusterrolebinding + labels: + app.kubernetes.io/name: {{ include "kubeops.name" . }} + helm.sh/chart: {{ include "kubeops.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "kubeops.fullname" . }}-clusterrole +subjects: +- kind: ServiceAccount + name: {{ include "kubeops.fullname" . }}-sa + namespace: {{ .Release.Namespace }} diff --git a/helm/kubeops/templates/configmap.yaml b/helm/kubeops/templates/configmap.yaml new file mode 100644 index 000000000..8c09822df --- /dev/null +++ b/helm/kubeops/templates/configmap.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "kubeops.fullname" . }}-configmap + labels: + app.kubernetes.io/name: {{ include "kubeops.name" . }} + helm.sh/chart: {{ include "kubeops.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +data: + kubeopsconfig.yaml: | + {{- with .Values.kubeopsconfig }} + {{- toYaml . | nindent 4 }} + {{- end }} + diff --git a/helm/kubeops/templates/deployment.yaml b/helm/kubeops/templates/deployment.yaml new file mode 100644 index 000000000..c2922c71f --- /dev/null +++ b/helm/kubeops/templates/deployment.yaml @@ -0,0 +1,40 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ include "kubeops.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "kubeops.name" . }} + helm.sh/chart: {{ include "kubeops.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + component: controller + app: kubeops +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + component: controller + app: kubeops + template: + metadata: + labels: + component: controller + app: kubeops + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + spec: + serviceAccountName: {{ include "kubeops.fullname" . }}-sa + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: config-volume + mountPath: "/config" + env: + - name: KUBEOPS_CONFIG_PATH + value: "/config/" + volumes: + - name: config-volume + configMap: + name: {{ include "kubeops.fullname" . }}-configmap diff --git a/helm/kubeops/templates/serviceaccount.yaml b/helm/kubeops/templates/serviceaccount.yaml new file mode 100644 index 000000000..7fe2297ea --- /dev/null +++ b/helm/kubeops/templates/serviceaccount.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "kubeops.fullname" . }}-sa + labels: + app.kubernetes.io/name: {{ include "kubeops.name" . }} + helm.sh/chart: {{ include "kubeops.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} diff --git a/helm/kubeops/values.yaml b/helm/kubeops/values.yaml new file mode 100644 index 000000000..199759bf6 --- /dev/null +++ b/helm/kubeops/values.yaml @@ -0,0 +1,132 @@ +# Default values for kubeops. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: infracloud/kubeops + tag: "0.1" + pullPolicy: Always + +nameOverride: "" +fullnameOverride: "" + +kubeopsconfig: + ## Resources you want to watch + resources: + - name: pods + namespaces: + - all + events: + - delete + - name: services + namespaces: + - all + events: + - delete + - name: deployments + namespaces: + - all + events: + - delete + - name: ingresses + namespaces: + - all + events: + - delete + - name: nodes + namespaces: + - all + events: + - delete + - name: namespaces + namespaces: + - all + events: + - delete + - name: persistentvolumes + namespaces: + - all + events: + - delete + - name: secrets + namespaces: + - all + events: + - delete + - name: configmaps + namespaces: + - all + events: + - delete + - name: daemonsets + namespaces: + - all + events: + - delete + - name: jobs + namespaces: + - all + events: + - delete + + # Events you want to watch + events: + types: + - normal + - warning + + # RBAC events you want to watch + #rbac: + # - name: roles + # namespaces: + # - all + # events: + # - create + # - delete + # - name: rolebindings + # namespaces: + # - all + # events: + # - create + # - delete + # - name: clusterroles + # namespaces: + # - all + # events: + # - create + # - delete + # - name: clusterrolebindings + # namespace: + # - all + # events: + # - create + # - delete + # + # Recommendations you want to receive + recommendations: true + + # Channels configuration + communications: + slack: + channel: 'SLACK_CHANNEL' + token: 'SLACK_API_TOKEN' + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {}