From b2f82bd5fe342a10083231af152fa59e08d928dd Mon Sep 17 00:00:00 2001 From: daiming Date: Fri, 5 Nov 2021 17:38:25 +0800 Subject: [PATCH] helm chart, init version[D Signed-off-by: daiming --- charts/bfe-ingress-controller/.helmignore | 23 +++++ charts/bfe-ingress-controller/Chart.yaml | 11 +++ .../templates/NOTES.txt | 20 ++++ .../templates/_helpers.tpl | 62 ++++++++++++ .../templates/deployment.yaml | 62 ++++++++++++ .../bfe-ingress-controller/templates/hpa.yaml | 28 ++++++ .../templates/rbac.yaml | 74 ++++++++++++++ .../templates/service.yaml | 16 +++ .../templates/serviceaccount.yaml | 12 +++ charts/bfe-ingress-controller/values.yaml | 97 +++++++++++++++++++ 10 files changed, 405 insertions(+) create mode 100644 charts/bfe-ingress-controller/.helmignore create mode 100644 charts/bfe-ingress-controller/Chart.yaml create mode 100644 charts/bfe-ingress-controller/templates/NOTES.txt create mode 100644 charts/bfe-ingress-controller/templates/_helpers.tpl create mode 100644 charts/bfe-ingress-controller/templates/deployment.yaml create mode 100644 charts/bfe-ingress-controller/templates/hpa.yaml create mode 100644 charts/bfe-ingress-controller/templates/rbac.yaml create mode 100644 charts/bfe-ingress-controller/templates/service.yaml create mode 100644 charts/bfe-ingress-controller/templates/serviceaccount.yaml create mode 100644 charts/bfe-ingress-controller/values.yaml diff --git a/charts/bfe-ingress-controller/.helmignore b/charts/bfe-ingress-controller/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/bfe-ingress-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/bfe-ingress-controller/Chart.yaml b/charts/bfe-ingress-controller/Chart.yaml new file mode 100644 index 00000000..2ae02b42 --- /dev/null +++ b/charts/bfe-ingress-controller/Chart.yaml @@ -0,0 +1,11 @@ +apiVersion: v2 +name: bfe-ingress-controller +description: Helm chart for BFE Ingress Controller +type: application +version: 0.1.0 +appVersion: "0.2.1" +keywords: + - ingress + - bfe +home: https://github.com/bfenetworks/ingress-bfe +icon: https://landscape.cncf.io/logos/bfe.svg diff --git a/charts/bfe-ingress-controller/templates/NOTES.txt b/charts/bfe-ingress-controller/templates/NOTES.txt new file mode 100644 index 00000000..e0f93e6c --- /dev/null +++ b/charts/bfe-ingress-controller/templates/NOTES.txt @@ -0,0 +1,20 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "bfe-ingress-controller.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "bfe-ingress-controller.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "bfe-ingress-controller.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.containerPort.http }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "bfe-ingress-controller.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} + +2. Test HTTP port, return 500 + curl -v $(echo http://$NODE_IP:$NODE_PORT) + diff --git a/charts/bfe-ingress-controller/templates/_helpers.tpl b/charts/bfe-ingress-controller/templates/_helpers.tpl new file mode 100644 index 00000000..9fd5a56d --- /dev/null +++ b/charts/bfe-ingress-controller/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "bfe-ingress-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 "bfe-ingress-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 "bfe-ingress-controller.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "bfe-ingress-controller.labels" -}} +helm.sh/chart: {{ include "bfe-ingress-controller.chart" . }} +{{ include "bfe-ingress-controller.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "bfe-ingress-controller.selectorLabels" -}} +app.kubernetes.io/name: {{ include "bfe-ingress-controller.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "bfe-ingress-controller.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "bfe-ingress-controller.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/bfe-ingress-controller/templates/deployment.yaml b/charts/bfe-ingress-controller/templates/deployment.yaml new file mode 100644 index 00000000..ebbfa5d0 --- /dev/null +++ b/charts/bfe-ingress-controller/templates/deployment.yaml @@ -0,0 +1,62 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "bfe-ingress-controller.fullname" . }} + labels: + {{- include "bfe-ingress-controller.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "bfe-ingress-controller.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "bfe-ingress-controller.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "bfe-ingress-controller.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + {{- if .Values.scope.namespaces }} + - "-n" + - {{ .Values.scope.namespaces | quote}} + {{- end }} + ports: + {{- range $key, $value := .Values.containerPort }} + - name: {{ $key }} + containerPort: {{ $value }} + protocol: TCP + {{- end }} + livenessProbe: {{ toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: {{ toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- 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/bfe-ingress-controller/templates/hpa.yaml b/charts/bfe-ingress-controller/templates/hpa.yaml new file mode 100644 index 00000000..5448f0e2 --- /dev/null +++ b/charts/bfe-ingress-controller/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "bfe-ingress-controller.fullname" . }} + labels: + {{- include "bfe-ingress-controller.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "bfe-ingress-controller.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/bfe-ingress-controller/templates/rbac.yaml b/charts/bfe-ingress-controller/templates/rbac.yaml new file mode 100644 index 00000000..cf61069b --- /dev/null +++ b/charts/bfe-ingress-controller/templates/rbac.yaml @@ -0,0 +1,74 @@ +{{- if .Values.rbac.create }} + +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + {{- include "bfe-ingress-controller.labels" . | nindent 4 }} + name: {{ include "bfe-ingress-controller.fullname" . }} +rules: + - apiGroups: + - "" + resources: + - endpoints + - services + - secrets + - namespaces + - nodes + verbs: + - get + - list + - watch + - apiGroups: + - extensions + - networking.k8s.io + resources: + - ingresses + verbs: + - get + - list + - watch + - update + - patch + - apiGroups: + - "" + resources: + - events + verbs: + - create + - patch + - update + - apiGroups: + - networking.k8s.io + resources: + - ingresses/status + verbs: + - update + - patch + - apiGroups: + - networking.k8s.io + resources: + - ingressclasses + verbs: + - get + - list + - watch + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + {{- include "bfe-ingress-controller.labels" . | nindent 4 }} + name: {{ include "bfe-ingress-controller.fullname" . }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "bfe-ingress-controller.fullname" . }} +subjects: + - kind: ServiceAccount + name: {{ template "bfe-ingress-controller.serviceAccountName" . }} + namespace: {{ .Release.Namespace | quote }} + +{{- end }} + diff --git a/charts/bfe-ingress-controller/templates/service.yaml b/charts/bfe-ingress-controller/templates/service.yaml new file mode 100644 index 00000000..f0e9c969 --- /dev/null +++ b/charts/bfe-ingress-controller/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "bfe-ingress-controller.fullname" . }} + labels: + {{- include "bfe-ingress-controller.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + {{- range $key, $value := .Values.containerPort }} + - name: {{ $key }} + port: {{ $value }} + targetPort: {{ $value }} + {{- end }} + selector: + {{- include "bfe-ingress-controller.selectorLabels" . | nindent 4 }} diff --git a/charts/bfe-ingress-controller/templates/serviceaccount.yaml b/charts/bfe-ingress-controller/templates/serviceaccount.yaml new file mode 100644 index 00000000..5fe44224 --- /dev/null +++ b/charts/bfe-ingress-controller/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "bfe-ingress-controller.serviceAccountName" . }} + labels: + {{- include "bfe-ingress-controller.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/bfe-ingress-controller/values.yaml b/charts/bfe-ingress-controller/values.yaml new file mode 100644 index 00000000..80626d11 --- /dev/null +++ b/charts/bfe-ingress-controller/values.yaml @@ -0,0 +1,97 @@ +# Default values for bfe-ingress-controller. +replicaCount: 1 + +image: + repository: bfenetworks/bfe-ingress-controller + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +containerPort: + http: 8080 + https: 8443 + monitor: 8421 + +livenessProbe: + httpGet: + path: "/" + port: 8421 + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 5 + timeoutSeconds: 1 + successThreshold: 1 + failureThreshold: 5 + +readinessProbe: + httpGet: + path: "/" + port: 8421 + scheme: HTTP + initialDelaySeconds: 10 + periodSeconds: 5 + timeoutSeconds: 1 + successThreshold: 1 + failureThreshold: 3 + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: NodePort + +scope: {} + # Set namespaces the controller watch, delimited by ',' + # Default to all namespace + # namespaces: namespace1,namespace2 + +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 + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +rbac: + create: true