From 213a51a0bb5ed9658de2d9fb2d3676f5d803857e Mon Sep 17 00:00:00 2001 From: samir-tahir Date: Thu, 14 Nov 2024 20:07:34 +0000 Subject: [PATCH] test --- .gitignore | 3 - charts/github-app-operator/.helmignore | 23 +++ charts/github-app-operator/Chart.yaml | 28 ++++ .../templates/_helpers.tpl | 62 ++++++++ .../templates/deployment.yaml | 111 ++++++++++++++ .../templates/githubapp-crd.yaml | 135 ++++++++++++++++++ .../templates/leader-election-rbac.yaml | 59 ++++++++ .../templates/manager-rbac.yaml | 94 ++++++++++++ .../templates/metrics-reader-rbac.yaml | 14 ++ .../templates/metrics-service.yaml | 17 +++ .../templates/proxy-rbac.yaml | 40 ++++++ .../templates/selfsigned-issuer.yaml | 13 ++ .../templates/serviceaccount.yaml | 11 ++ .../templates/serving-cert.yaml | 21 +++ .../validating-webhook-configuration.yaml | 31 ++++ .../templates/webhook-service.yaml | 15 ++ charts/github-app-operator/values.yaml | 83 +++++++++++ 17 files changed, 757 insertions(+), 3 deletions(-) create mode 100644 charts/github-app-operator/.helmignore create mode 100644 charts/github-app-operator/Chart.yaml create mode 100644 charts/github-app-operator/templates/_helpers.tpl create mode 100644 charts/github-app-operator/templates/deployment.yaml create mode 100644 charts/github-app-operator/templates/githubapp-crd.yaml create mode 100644 charts/github-app-operator/templates/leader-election-rbac.yaml create mode 100644 charts/github-app-operator/templates/manager-rbac.yaml create mode 100644 charts/github-app-operator/templates/metrics-reader-rbac.yaml create mode 100644 charts/github-app-operator/templates/metrics-service.yaml create mode 100644 charts/github-app-operator/templates/proxy-rbac.yaml create mode 100644 charts/github-app-operator/templates/selfsigned-issuer.yaml create mode 100644 charts/github-app-operator/templates/serviceaccount.yaml create mode 100644 charts/github-app-operator/templates/serving-cert.yaml create mode 100644 charts/github-app-operator/templates/validating-webhook-configuration.yaml create mode 100644 charts/github-app-operator/templates/webhook-service.yaml create mode 100644 charts/github-app-operator/values.yaml diff --git a/.gitignore b/.gitignore index 286f006..0cd4962 100644 --- a/.gitignore +++ b/.gitignore @@ -8,9 +8,6 @@ bin/* Dockerfile.cross -# helm charts -charts - # Test binary, built with `go test -c` *.test diff --git a/charts/github-app-operator/.helmignore b/charts/github-app-operator/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/github-app-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/github-app-operator/Chart.yaml b/charts/github-app-operator/Chart.yaml new file mode 100644 index 0000000..a54c6c3 --- /dev/null +++ b/charts/github-app-operator/Chart.yaml @@ -0,0 +1,28 @@ +apiVersion: v2 +name: github-app-operator +description: A Helm chart for Kubernetes +# 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.1.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.1.0" + +dependencies: + - name: cert-manager + repository: https://charts.jetstack.io + condition: certmanager.enabled + alias: certmanager + version: "v1.12.2" diff --git a/charts/github-app-operator/templates/_helpers.tpl b/charts/github-app-operator/templates/_helpers.tpl new file mode 100644 index 0000000..213e37b --- /dev/null +++ b/charts/github-app-operator/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "github-app-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 "github-app-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 "github-app-operator.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "github-app-operator.labels" -}} +helm.sh/chart: {{ include "github-app-operator.chart" . }} +{{ include "github-app-operator.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "github-app-operator.selectorLabels" -}} +app.kubernetes.io/name: {{ include "github-app-operator.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "github-app-operator.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "github-app-operator.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/github-app-operator/templates/deployment.yaml b/charts/github-app-operator/templates/deployment.yaml new file mode 100644 index 0000000..7aa80e0 --- /dev/null +++ b/charts/github-app-operator/templates/deployment.yaml @@ -0,0 +1,111 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "github-app-operator.fullname" . }}-controller-manager + labels: + app.kubernetes.io/component: manager + app.kubernetes.io/created-by: github-app-operator + app.kubernetes.io/part-of: github-app-operator + control-plane: controller-manager + {{- include "github-app-operator.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.controllerManager.replicas }} + selector: + matchLabels: + control-plane: controller-manager + {{- include "github-app-operator.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + control-plane: controller-manager + {{- include "github-app-operator.selectorLabels" . | nindent 8 }} + annotations: + kubectl.kubernetes.io/default-container: manager + spec: + containers: + - args: {{- toYaml .Values.controllerManager.manager.args | nindent 8 }} + command: + - /manager + env: + - name: CHECK_INTERVAL + value: {{ quote .Values.controllerManager.manager.env.checkInterval }} + - name: EXPIRY_THRESHOLD + value: {{ quote .Values.controllerManager.manager.env.expiryThreshold }} + - name: DEBUG_LOG + value: {{ quote .Values.controllerManager.manager.env.debugLog }} + - name: VAULT_ROLE + value: {{ quote .Values.controllerManager.manager.env.vaultRole }} + - name: VAULT_ROLE_AUDIENCE + value: {{ quote .Values.controllerManager.manager.env.vaultRoleAudience }} + - name: VAULT_ADDR + value: {{ quote .Values.controllerManager.manager.env.vaultAddr }} + - name: GITHUB_PROXY + value: {{ quote .Values.controllerManager.manager.env.githubProxy }} + - name: VAULT_NAMESPACE + value: {{ quote .Values.controllerManager.manager.env.vaultNamespace }} + - name: VAULT_PROXY_ADDR + value: {{ quote .Values.controllerManager.manager.env.vaultProxyAddr }} + - name: ENABLE_WEBHOOKS + value: {{ quote .Values.controllerManager.manager.env.enableWebhooks }} + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag + | default .Chart.AppVersion }} + imagePullPolicy: {{ .Values.controllerManager.manager.imagePullPolicy }} + livenessProbe: + httpGet: + path: /healthz + port: 8081 + initialDelaySeconds: 15 + periodSeconds: 20 + name: manager + ports: + - containerPort: 9443 + name: webhook-server + protocol: TCP + readinessProbe: + httpGet: + path: /readyz + port: 8081 + initialDelaySeconds: 5 + periodSeconds: 10 + resources: {{- toYaml .Values.controllerManager.manager.resources | nindent 10 + }} + securityContext: {{- toYaml .Values.controllerManager.manager.containerSecurityContext + | nindent 10 }} + volumeMounts: + {{- if .Values.webhook.enabled -}} + - mountPath: /tmp/k8s-webhook-server/serving-certs + name: cert + readOnly: true + {{- end }} + - mountPath: /var/run/github-app-secrets + name: github-app-secrets + - args: {{- toYaml .Values.controllerManager.kubeRbacProxy.args | nindent 8 }} + env: + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + image: {{ .Values.controllerManager.kubeRbacProxy.image.repository }}:{{ .Values.controllerManager.kubeRbacProxy.image.tag + | default .Chart.AppVersion }} + name: kube-rbac-proxy + ports: + - containerPort: 8443 + name: https + protocol: TCP + resources: {{- toYaml .Values.controllerManager.kubeRbacProxy.resources | nindent + 10 }} + securityContext: {{- toYaml .Values.controllerManager.kubeRbacProxy.containerSecurityContext + | nindent 10 }} + securityContext: {{- toYaml .Values.controllerManager.podSecurityContext | nindent + 8 }} + serviceAccountName: {{ include "github-app-operator.fullname" . }}-controller-manager + terminationGracePeriodSeconds: 10 + volumes: + {{- if .Values.webhook.enabled -}} + - name: cert + secret: + defaultMode: 420 + secretName: webhook-server-cert + {{- end }} + - emptyDir: {} + name: github-app-secrets \ No newline at end of file diff --git a/charts/github-app-operator/templates/githubapp-crd.yaml b/charts/github-app-operator/templates/githubapp-crd.yaml new file mode 100644 index 0000000..dcfd9af --- /dev/null +++ b/charts/github-app-operator/templates/githubapp-crd.yaml @@ -0,0 +1,135 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: githubapps.githubapp.samir.io + annotations: + {{- if .Values.webhook.enabled -}} + cert-manager.io/inject-ca-from: '{{ .Release.Namespace }}/{{ include "github-app-operator.fullname" + . }}-serving-cert' + {{- end }} + controller-gen.kubebuilder.io/version: v0.14.0 + labels: + {{- include "github-app-operator.labels" . | nindent 4 }} +spec: + {{- if .Values.webhook.enabled -}} + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + name: '{{ include "github-app-operator.fullname" . }}-webhook-service' + namespace: '{{ .Release.Namespace }}' + path: /convert + conversionReviewVersions: + - v1 + {{- end }} + group: githubapp.samir.io + names: + kind: GithubApp + listKind: GithubAppList + plural: githubapps + singular: githubapp + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.appId + name: App ID + type: string + - jsonPath: .spec.accessTokenSecret + name: Access Token Secret + type: string + - jsonPath: .spec.installId + name: Install ID + type: string + - jsonPath: .status.expiresAt + name: Expires At + type: string + - jsonPath: .status.error + name: Error + type: string + name: v1 + schema: + openAPIV3Schema: + description: GithubApp is the Schema for the githubapps API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: GithubAppSpec defines the desired state of GithubApp + properties: + accessTokenSecret: + type: string + appId: + type: integer + googlePrivateKeySecret: + type: string + installId: + type: integer + privateKeySecret: + type: string + rolloutDeployment: + description: RolloutDeploymentSpec defines the specification for restarting + pods + properties: + labels: + additionalProperties: + type: string + type: object + type: object + vaultPrivateKey: + description: VaultPrivateKeySpec defines the spec for retrieving the + private key from Vault + properties: + mountPath: + type: string + secretKey: + type: string + secretPath: + type: string + required: + - mountPath + - secretKey + - secretPath + type: object + required: + - accessTokenSecret + - appId + - installId + type: object + status: + description: GithubAppStatus defines the observed state of GithubApp + properties: + error: + description: Error field to store error messages + type: string + expiresAt: + description: Expiry of access token + format: date-time + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] \ No newline at end of file diff --git a/charts/github-app-operator/templates/leader-election-rbac.yaml b/charts/github-app-operator/templates/leader-election-rbac.yaml new file mode 100644 index 0000000..aea639a --- /dev/null +++ b/charts/github-app-operator/templates/leader-election-rbac.yaml @@ -0,0 +1,59 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ include "github-app-operator.fullname" . }}-leader-election-role + labels: + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: github-app-operator + app.kubernetes.io/part-of: github-app-operator + {{- include "github-app-operator.labels" . | nindent 4 }} +rules: +- apiGroups: + - "" + resources: + - configmaps + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ include "github-app-operator.fullname" . }}-leader-election-rolebinding + labels: + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: github-app-operator + app.kubernetes.io/part-of: github-app-operator + {{- include "github-app-operator.labels" . | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: '{{ include "github-app-operator.fullname" . }}-leader-election-role' +subjects: +- kind: ServiceAccount + name: '{{ include "github-app-operator.fullname" . }}-controller-manager' + namespace: '{{ .Release.Namespace }}' \ No newline at end of file diff --git a/charts/github-app-operator/templates/manager-rbac.yaml b/charts/github-app-operator/templates/manager-rbac.yaml new file mode 100644 index 0000000..c9af6e7 --- /dev/null +++ b/charts/github-app-operator/templates/manager-rbac.yaml @@ -0,0 +1,94 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "github-app-operator.fullname" . }}-manager-role + labels: + {{- include "github-app-operator.labels" . | nindent 4 }} +rules: +- apiGroups: + - "" + resources: + - secrets + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - apps + resources: + - deployments + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +- apiGroups: + - "" + resources: + - serviceaccounts + verbs: + - create + - get +- apiGroups: + - "" + resources: + - serviceaccounts/token + verbs: + - create + - get +- apiGroups: + - githubapp.samir.io + resources: + - githubapps + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - githubapp.samir.io + resources: + - githubapps/finalizers + verbs: + - update +- apiGroups: + - githubapp.samir.io + resources: + - githubapps/status + verbs: + - get + - patch + - update +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "github-app-operator.fullname" . }}-manager-rolebinding + labels: + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: github-app-operator + app.kubernetes.io/part-of: github-app-operator + {{- include "github-app-operator.labels" . | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: '{{ include "github-app-operator.fullname" . }}-manager-role' +subjects: +- kind: ServiceAccount + name: '{{ include "github-app-operator.fullname" . }}-controller-manager' + namespace: '{{ .Release.Namespace }}' \ No newline at end of file diff --git a/charts/github-app-operator/templates/metrics-reader-rbac.yaml b/charts/github-app-operator/templates/metrics-reader-rbac.yaml new file mode 100644 index 0000000..fa82930 --- /dev/null +++ b/charts/github-app-operator/templates/metrics-reader-rbac.yaml @@ -0,0 +1,14 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "github-app-operator.fullname" . }}-metrics-reader + labels: + app.kubernetes.io/component: kube-rbac-proxy + app.kubernetes.io/created-by: github-app-operator + app.kubernetes.io/part-of: github-app-operator + {{- include "github-app-operator.labels" . | nindent 4 }} +rules: +- nonResourceURLs: + - /metrics + verbs: + - get \ No newline at end of file diff --git a/charts/github-app-operator/templates/metrics-service.yaml b/charts/github-app-operator/templates/metrics-service.yaml new file mode 100644 index 0000000..62193b5 --- /dev/null +++ b/charts/github-app-operator/templates/metrics-service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "github-app-operator.fullname" . }}-controller-manager-metrics-service + labels: + app.kubernetes.io/component: kube-rbac-proxy + app.kubernetes.io/created-by: github-app-operator + app.kubernetes.io/part-of: github-app-operator + control-plane: controller-manager + {{- include "github-app-operator.labels" . | nindent 4 }} +spec: + type: {{ .Values.metricsService.type }} + selector: + control-plane: controller-manager + {{- include "github-app-operator.selectorLabels" . | nindent 4 }} + ports: + {{- .Values.metricsService.ports | toYaml | nindent 2 }} \ No newline at end of file diff --git a/charts/github-app-operator/templates/proxy-rbac.yaml b/charts/github-app-operator/templates/proxy-rbac.yaml new file mode 100644 index 0000000..dfeb4b7 --- /dev/null +++ b/charts/github-app-operator/templates/proxy-rbac.yaml @@ -0,0 +1,40 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "github-app-operator.fullname" . }}-proxy-role + labels: + app.kubernetes.io/component: kube-rbac-proxy + app.kubernetes.io/created-by: github-app-operator + app.kubernetes.io/part-of: github-app-operator + {{- include "github-app-operator.labels" . | nindent 4 }} +rules: +- apiGroups: + - authentication.k8s.io + resources: + - tokenreviews + verbs: + - create +- apiGroups: + - authorization.k8s.io + resources: + - subjectaccessreviews + verbs: + - create +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "github-app-operator.fullname" . }}-proxy-rolebinding + labels: + app.kubernetes.io/component: kube-rbac-proxy + app.kubernetes.io/created-by: github-app-operator + app.kubernetes.io/part-of: github-app-operator + {{- include "github-app-operator.labels" . | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: '{{ include "github-app-operator.fullname" . }}-proxy-role' +subjects: +- kind: ServiceAccount + name: '{{ include "github-app-operator.fullname" . }}-controller-manager' + namespace: '{{ .Release.Namespace }}' \ No newline at end of file diff --git a/charts/github-app-operator/templates/selfsigned-issuer.yaml b/charts/github-app-operator/templates/selfsigned-issuer.yaml new file mode 100644 index 0000000..193aa6d --- /dev/null +++ b/charts/github-app-operator/templates/selfsigned-issuer.yaml @@ -0,0 +1,13 @@ +{{- if .Values.webhook.enabled -}} +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + name: {{ include "github-app-operator.fullname" . }}-selfsigned-issuer + annotations: + "helm.sh/hook": post-install,post-upgrade + "helm.sh/hook-weight": "1" + labels: + {{- include "github-app-operator.labels" . | nindent 4 }} +spec: + selfSigned: {} +{{- end }} \ No newline at end of file diff --git a/charts/github-app-operator/templates/serviceaccount.yaml b/charts/github-app-operator/templates/serviceaccount.yaml new file mode 100644 index 0000000..3c90765 --- /dev/null +++ b/charts/github-app-operator/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "github-app-operator.fullname" . }}-controller-manager + labels: + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: github-app-operator + app.kubernetes.io/part-of: github-app-operator + {{- include "github-app-operator.labels" . | nindent 4 }} + annotations: + {{- toYaml .Values.controllerManager.serviceAccount.annotations | nindent 4 }} \ No newline at end of file diff --git a/charts/github-app-operator/templates/serving-cert.yaml b/charts/github-app-operator/templates/serving-cert.yaml new file mode 100644 index 0000000..2ba53d2 --- /dev/null +++ b/charts/github-app-operator/templates/serving-cert.yaml @@ -0,0 +1,21 @@ +{{- if .Values.webhook.enabled -}} +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: {{ include "github-app-operator.fullname" . }}-serving-cert + annotations: + "helm.sh/hook": post-install,post-upgrade + "helm.sh/hook-weight": "2" + labels: + {{- include "github-app-operator.labels" . | nindent 4 }} +spec: + dnsNames: + - '{{ include "github-app-operator.fullname" . }}-webhook-service.{{ .Release.Namespace + }}.svc' + - '{{ include "github-app-operator.fullname" . }}-webhook-service.{{ .Release.Namespace + }}.svc.{{ .Values.kubernetesClusterDomain }}' + issuerRef: + kind: Issuer + name: '{{ include "github-app-operator.fullname" . }}-selfsigned-issuer' + secretName: webhook-server-cert +{{- end }} \ No newline at end of file diff --git a/charts/github-app-operator/templates/validating-webhook-configuration.yaml b/charts/github-app-operator/templates/validating-webhook-configuration.yaml new file mode 100644 index 0000000..e072f08 --- /dev/null +++ b/charts/github-app-operator/templates/validating-webhook-configuration.yaml @@ -0,0 +1,31 @@ +{{- if .Values.webhook.enabled -}} +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingWebhookConfiguration +metadata: + name: {{ include "github-app-operator.fullname" . }}-validating-webhook-configuration + annotations: + cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "github-app-operator.fullname" . }}-serving-cert + labels: + {{- include "github-app-operator.labels" . | nindent 4 }} +webhooks: +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: '{{ include "github-app-operator.fullname" . }}-webhook-service' + namespace: '{{ .Release.Namespace }}' + path: /validate-githubapp-samir-io-v1-githubapp + failurePolicy: Fail + name: vgithubapp.kb.io + rules: + - apiGroups: + - githubapp.samir.io + apiVersions: + - v1 + operations: + - CREATE + - UPDATE + resources: + - githubapps + sideEffects: None +{{- end }} \ No newline at end of file diff --git a/charts/github-app-operator/templates/webhook-service.yaml b/charts/github-app-operator/templates/webhook-service.yaml new file mode 100644 index 0000000..33bafe7 --- /dev/null +++ b/charts/github-app-operator/templates/webhook-service.yaml @@ -0,0 +1,15 @@ +{{- if .Values.webhook.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "github-app-operator.fullname" . }}-webhook-service + labels: + {{- include "github-app-operator.labels" . | nindent 4 }} +spec: + type: {{ .Values.webhook.webhookService.type }} + selector: + control-plane: controller-manager + {{- include "github-app-operator.selectorLabels" . | nindent 4 }} + ports: + {{- .Values.webhook.webhookService.ports | toYaml | nindent 2 }} +{{- end }} \ No newline at end of file diff --git a/charts/github-app-operator/values.yaml b/charts/github-app-operator/values.yaml new file mode 100644 index 0000000..535735a --- /dev/null +++ b/charts/github-app-operator/values.yaml @@ -0,0 +1,83 @@ +certmanager: + enabled: true + installCRDs: true +controllerManager: + kubeRbacProxy: + args: + - --secure-listen-address=0.0.0.0:8443 + - --upstream=http://127.0.0.1:8080/ + - --logtostderr=true + - --v=0 + containerSecurityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + image: + repository: gcr.io/kubebuilder/kube-rbac-proxy + tag: v0.15.0 + resources: + limits: + cpu: 500m + memory: 128Mi + requests: + cpu: 5m + memory: 64Mi + manager: + args: + - --health-probe-bind-address=:8081 + - --metrics-bind-address=127.0.0.1:8080 + - --leader-elect + containerSecurityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + env: + checkInterval: 5m + debugLog: "false" + enableWebhooks: "false" + expiryThreshold: 15m + githubProxy: "" + vaultAddr: http://vault.default:8200 + vaultNamespace: "" + vaultProxyAddr: "" + vaultRole: githubapp + vaultRoleAudience: githubapp + image: + repository: samirtahir91076/github-app-operator + tag: latest + imagePullPolicy: Never + resources: + limits: + cpu: 500m + memory: 128Mi + requests: + cpu: 10m + memory: 64Mi + podSecurityContext: + fsGroup: 65532 + runAsGroup: 65532 + runAsNonRoot: true + runAsUser: 65532 + seccompProfile: + type: RuntimeDefault + replicas: 1 + serviceAccount: + annotations: {} +kubernetesClusterDomain: cluster.local +metricsService: + ports: + - name: https + port: 8443 + protocol: TCP + targetPort: https + type: ClusterIP +webhook: + enabled: false + webhookService: + ports: + - port: 443 + protocol: TCP + targetPort: 9443 + type: ClusterIP