diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6854c9f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,23 @@ +name: Release Charts + +on: + push: + branches: + - main + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.5.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/charts/lh-operator/.helmignore b/charts/lh-operator/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/lh-operator/.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/lh-operator/Chart.yaml b/charts/lh-operator/Chart.yaml new file mode 100644 index 0000000..fc0e9d3 --- /dev/null +++ b/charts/lh-operator/Chart.yaml @@ -0,0 +1,26 @@ +# https://helm.sh/docs/topics/charts/#the-chartyaml-file +apiVersion: v2 +name: lh-operator-helm +description: LittleHorse Operator +icon: https://littlehorse.dev/img/logo.jpg + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.5.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "0.5.0" diff --git a/charts/lh-operator/templates/NOTES.txt b/charts/lh-operator/templates/NOTES.txt new file mode 100644 index 0000000..2952665 --- /dev/null +++ b/charts/lh-operator/templates/NOTES.txt @@ -0,0 +1 @@ +LittleHorse Operator diff --git a/charts/lh-operator/templates/_helpers.tpl b/charts/lh-operator/templates/_helpers.tpl new file mode 100644 index 0000000..e0089bd --- /dev/null +++ b/charts/lh-operator/templates/_helpers.tpl @@ -0,0 +1,66 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "lh-operator.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 "lh-operator.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 "lh-operator.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "lh-operator.labels" -}} +{{- if .Values.helm.addHelmLabels -}} +helm.sh/chart: {{ include "lh-operator.chart" . }} +{{ end }} +{{- include "lh-operator.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +{{- if .Values.helm.addHelmLabels }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "lh-operator.selectorLabels" -}} +app.kubernetes.io/name: {{ include "lh-operator.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "lh-operator.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "lh-operator.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/lh-operator/templates/deployment.yaml b/charts/lh-operator/templates/deployment.yaml new file mode 100644 index 0000000..fde94b9 --- /dev/null +++ b/charts/lh-operator/templates/deployment.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "lh-operator.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + kubernetes.io/app: lh-operator + {{- include "lh-operator.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicas }} + selector: + matchLabels: + {{- include "lh-operator.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + kubernetes.io/app: lh-operator + {{- include "lh-operator.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "lh-operator.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ include "lh-operator.fullname" . }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + resources: + {{- toYaml .Values.resources | nindent 12 }} + env: + - name: LHO_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: LHO_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + {{- 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/lh-operator/templates/lhclusters.littlehorse.io-v1.yml b/charts/lh-operator/templates/lhclusters.littlehorse.io-v1.yml new file mode 100644 index 0000000..2fad5ba --- /dev/null +++ b/charts/lh-operator/templates/lhclusters.littlehorse.io-v1.yml @@ -0,0 +1,266 @@ +# Generated by Fabric8 CRDGenerator, manual edits might get overwritten! +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: lhclusters.littlehorse.io +spec: + group: littlehorse.io + names: + kind: LHCluster + plural: lhclusters + shortNames: + - lhc + singular: lhcluster + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.kafka.clusterPartitions + name: partitions + type: integer + - jsonPath: .spec.server.replicas + name: REPLICAS + type: integer + - jsonPath: .spec.server.storage.volumeSize + name: VOLUMESIZE + type: string + - jsonPath: .status.problems + name: PROBLEMS + type: string + name: v1 + schema: + openAPIV3Schema: + properties: + spec: + properties: + kafka: + properties: + strimziClusterRef: + properties: + clusterName: + type: string + createTopics: + type: boolean + quotas: + properties: + producerByteRate: + nullable: true + type: integer + consumerByteRate: + nullable: true + type: integer + requestPercentage: + nullable: true + type: integer + controllerMutationRate: + nullable: true + type: number + type: object + listener: + properties: + tls: + type: boolean + port: + type: integer + authentication: + type: string + required: + - port + type: object + required: + - clusterName + - createTopics + - listener + type: object + replicationFactor: + type: integer + clusterPartitions: + type: integer + required: + - clusterPartitions + type: object + server: + properties: + listeners: + items: + properties: + name: + type: string + infrastructure: + properties: + ingress: + properties: + serverHostSuffix: + nullable: true + type: string + ingressClassName: + type: string + ingressAnnotations: + additionalProperties: + type: string + type: object + required: + - ingressClassName + type: object + type: object + tls: + properties: + secretRef: + properties: + name: + type: string + required: + - name + type: object + type: object + authentication: + properties: + type: + type: string + required: + - type + type: object + advertisedListeners: + properties: + bootstrap: + nullable: true + properties: + host: + nullable: true + type: string + type: object + servers: + items: + properties: + host: + type: string + port: + type: integer + required: + - host + - port + type: object + type: array + required: + - servers + type: object + port: + type: integer + required: + - name + - port + type: object + type: array + version: + type: string + image: + type: string + imagePullPolicy: + type: string + replicas: + minimum: 1.0 + type: integer + storage: + properties: + storageClassName: + type: string + volumeSize: + type: string + required: + - storageClassName + type: object + hotStandbyReplicas: + type: integer + compute: + nullable: true + properties: + cpu: + nullable: true + type: string + memory: + nullable: true + type: string + type: object + rackAwareness: + nullable: true + properties: + zoneKey: + type: string + zoneIds: + items: + type: string + type: array + required: + - zoneKey + - zoneIds + type: object + authentication: + properties: + mtls: + properties: + clientCaCert: + properties: + secretRef: + properties: + name: + type: string + required: + - name + type: object + required: + - secretRef + type: object + required: + - clientCaCert + type: object + oauth: + properties: + introspectionEndpointUrl: + type: string + credentials: + properties: + secretRef: + properties: + name: + type: string + required: + - name + type: object + required: + - secretRef + type: object + required: + - introspectionEndpointUrl + - credentials + type: object + type: object + template: + type: object + podAnnotations: + additionalProperties: + type: string + type: object + podLabels: + additionalProperties: + type: string + type: object + required: + - replicas + - storage + type: object + type: object + status: + properties: + lastBounceTime: + type: integer + lastBouncedPod: + type: integer + problems: + type: string + observedGeneration: + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/charts/lh-operator/templates/lhoperators.littlehorse.io-v1.yml b/charts/lh-operator/templates/lhoperators.littlehorse.io-v1.yml new file mode 100644 index 0000000..c1a8407 --- /dev/null +++ b/charts/lh-operator/templates/lhoperators.littlehorse.io-v1.yml @@ -0,0 +1,35 @@ +# Generated by Fabric8 CRDGenerator, manual edits might get overwritten! +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: lhoperators.littlehorse.io +spec: + group: littlehorse.io + names: + kind: LHOperator + plural: lhoperators + shortNames: + - lho + singular: lhoperator + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + properties: + spec: + type: object + status: + properties: + reconciledBy: + items: + type: string + type: array + observedGeneration: + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/charts/lh-operator/templates/role.yaml b/charts/lh-operator/templates/role.yaml new file mode 100644 index 0000000..22af476 --- /dev/null +++ b/charts/lh-operator/templates/role.yaml @@ -0,0 +1,27 @@ +{{- if .Values.role.create -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ include "lh-operator.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "lh-operator.labels" . | nindent 4 }} +rules: +- apiGroups: [""] + resources: ["secrets", "pods", "configmaps", "serviceaccounts", "persistentvolumeclaims", "services"] + verbs: ["get", "list", "watch", "create", "delete", "patch", "update"] +- apiGroups: ["networking.k8s.io"] + resources: ["ingresses"] + verbs: ["get", "list", "watch", "create", "delete", "patch", "update"] +- apiGroups: ["coordination.k8s.io"] + resources: ["leases"] + verbs: ["get", "list", "watch", "create", "delete", "patch", "update"] +- apiGroups: ["littlehorse.io"] + resources: ["*"] + verbs: ["*"] +{{- if .Values.strimzi.grantPermissions }} +- apiGroups: ["kafka.strimzi.io"] + resources: ["kafkausers", "kafkatopics"] + verbs: ["get", "list", "watch", "create", "delete", "patch", "update"] +{{- end -}} +{{- end }} diff --git a/charts/lh-operator/templates/rolebinding.yaml b/charts/lh-operator/templates/rolebinding.yaml new file mode 100644 index 0000000..8106d87 --- /dev/null +++ b/charts/lh-operator/templates/rolebinding.yaml @@ -0,0 +1,17 @@ +{{- if .Values.role.create -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ include "lh-operator.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "lh-operator.labels" . | nindent 4 }} +subjects: + - kind: ServiceAccount + name: {{ include "lh-operator.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} +roleRef: + kind: Role + name: {{ include "lh-operator.fullname" . }} + apiGroup: rbac.authorization.k8s.io +{{- end }} diff --git a/charts/lh-operator/templates/serviceaccount.yaml b/charts/lh-operator/templates/serviceaccount.yaml new file mode 100644 index 0000000..1a77725 --- /dev/null +++ b/charts/lh-operator/templates/serviceaccount.yaml @@ -0,0 +1,9 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "lh-operator.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "lh-operator.labels" . | nindent 4 }} +{{- end }} diff --git a/charts/lh-operator/values.yaml b/charts/lh-operator/values.yaml new file mode 100644 index 0000000..132c3ae --- /dev/null +++ b/charts/lh-operator/values.yaml @@ -0,0 +1,68 @@ +# Default values for lh-operator. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicas: 1 + +image: + repository: public.ecr.aws/littlehorse/lh-operator + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] + +# Overrides lh-operator.name variable +nameOverride: "lh-operator" + +# Overrides lh-operator.fullname variable +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +role: + # Specifies whether or not create a role for the operator + create: true + +strimzi: + # Specifies if the operator can create Strimzi topics and users + grantPermissions: true + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +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: {} + +helm: + addHelmLabels: true