From 091519d2217ba9b2c2bd6382d03b0a7fee475c84 Mon Sep 17 00:00:00 2001 From: Vicente Cheng Date: Wed, 4 Sep 2024 10:34:49 +0800 Subject: [PATCH] charts: initinal release for harvester-networkfs-manager Signed-off-by: Vicente Cheng --- .../harvester-networkfs-manager/.helmignore | 23 +++ charts/harvester-networkfs-manager/Chart.yaml | 27 ++++ .../templates/NOTES.txt | 1 + .../templates/_helpers.tpl | 62 ++++++++ .../harvesterhci.io_networkfilesystems.yaml | 147 ++++++++++++++++++ .../templates/daemonset.yaml | 113 ++++++++++++++ .../templates/rbac.yaml | 43 +++++ .../harvester-networkfs-manager/values.yaml | 44 ++++++ 8 files changed, 460 insertions(+) create mode 100644 charts/harvester-networkfs-manager/.helmignore create mode 100644 charts/harvester-networkfs-manager/Chart.yaml create mode 100644 charts/harvester-networkfs-manager/templates/NOTES.txt create mode 100644 charts/harvester-networkfs-manager/templates/_helpers.tpl create mode 100644 charts/harvester-networkfs-manager/templates/crds/harvesterhci.io_networkfilesystems.yaml create mode 100644 charts/harvester-networkfs-manager/templates/daemonset.yaml create mode 100644 charts/harvester-networkfs-manager/templates/rbac.yaml create mode 100644 charts/harvester-networkfs-manager/values.yaml diff --git a/charts/harvester-networkfs-manager/.helmignore b/charts/harvester-networkfs-manager/.helmignore new file mode 100644 index 000000000..0e8a0eb3 --- /dev/null +++ b/charts/harvester-networkfs-manager/.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/harvester-networkfs-manager/Chart.yaml b/charts/harvester-networkfs-manager/Chart.yaml new file mode 100644 index 000000000..798e9fc3 --- /dev/null +++ b/charts/harvester-networkfs-manager/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v2 +name: harvester-networkfs-manager +description: A Helm chart for Harvester Network Filesystem Manager + +# 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" + +maintainers: + - name: harvester diff --git a/charts/harvester-networkfs-manager/templates/NOTES.txt b/charts/harvester-networkfs-manager/templates/NOTES.txt new file mode 100644 index 000000000..415833b8 --- /dev/null +++ b/charts/harvester-networkfs-manager/templates/NOTES.txt @@ -0,0 +1 @@ +The harvester-networkfs-manager has been installed into "{{ .Release.Namespace }}" namespace. diff --git a/charts/harvester-networkfs-manager/templates/_helpers.tpl b/charts/harvester-networkfs-manager/templates/_helpers.tpl new file mode 100644 index 000000000..dce438ab --- /dev/null +++ b/charts/harvester-networkfs-manager/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "harvester-networkfs-manager.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 "harvester-networkfs-manager.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 "harvester-networkfs-manager.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "harvester-networkfs-manager.labels" -}} +helm.sh/chart: {{ include "harvester-networkfs-manager.chart" . }} +{{ include "harvester-networkfs-manager.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "harvester-networkfs-manager.selectorLabels" -}} +app.kubernetes.io/name: {{ include "harvester-networkfs-manager.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "harvester-networkfs-manager.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "harvester-networkfs-manager.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/harvester-networkfs-manager/templates/crds/harvesterhci.io_networkfilesystems.yaml b/charts/harvester-networkfs-manager/templates/crds/harvesterhci.io_networkfilesystems.yaml new file mode 100644 index 000000000..091cde2f --- /dev/null +++ b/charts/harvester-networkfs-manager/templates/crds/harvesterhci.io_networkfilesystems.yaml @@ -0,0 +1,147 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + {} + name: networkfilesystems.harvesterhci.io +spec: + group: harvesterhci.io + names: + kind: NetworkFilesystem + listKind: NetworkFilesystemList + plural: networkfilesystems + shortNames: + - netfilesystem + - netfilesystems + singular: networkfilesystem + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.desiredState + name: DesiredState + type: string + - jsonPath: .status.endpoint + name: Endpoint + type: string + - jsonPath: .status.status + name: EndpointStatus + type: string + - jsonPath: .status.state + name: State + type: string + - jsonPath: .status.type + name: Type + type: string + name: v1beta1 + schema: + openAPIV3Schema: + 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: + properties: + desiredState: + description: desired state of the networkFS endpoint, options are + "Disabled", "Enabling", "Enabled", "Disabling", or "Unknown" + type: string + networkFSName: + description: name of the networkFS to which the endpoint is exported + type: string + perferredNodes: + description: perferred nodes to which the networkFS endpoint is exported + type: string + provisioner: + description: the provider of this networkfilesystem + type: string + required: + - desiredState + - networkFSName + type: object + status: + properties: + conditions: + default: [] + description: the conditions of the networkFS + items: + properties: + lastTransitionTime: + format: date-time + type: string + message: + type: string + reason: + type: string + status: + type: string + type: + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + endpoint: + default: "" + description: the current Endpoint of the networkFS + type: string + mountOpts: + description: the recommend mount options for the networkFS endpoint + type: string + state: + default: Disabled + description: the current state of the networkFS endpoint, options + are "Enabled", "Enabling", "Disabling", "Disabled", or "Unknown" + enum: + - Enabled + - Enabling + - Disabling + - Disabled + - Unknown + type: string + status: + default: NotReady + description: the status of the endpoint + enum: + - Ready + - NotReady + - Reconciling + - Unknown + type: string + type: + default: NFS + description: the type of the networkFS endpoint, options are "NFS", + or "Unknown" + enum: + - NFS + - Unknown + type: string + required: + - endpoint + - state + - status + - type + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/charts/harvester-networkfs-manager/templates/daemonset.yaml b/charts/harvester-networkfs-manager/templates/daemonset.yaml new file mode 100644 index 000000000..eda6e3d7 --- /dev/null +++ b/charts/harvester-networkfs-manager/templates/daemonset.yaml @@ -0,0 +1,113 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: {{ include "harvester-networkfs-manager.name" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "harvester-networkfs-manager.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "harvester-networkfs-manager.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "harvester-networkfs-manager.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "harvester-networkfs-manager.name" . }} + hostNetwork: true + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - networkfs-manager + {{- if .Values.debug }} + - "--debug" + {{- end }} + env: + {{- with .Values.vendorFilter }} + - name: NDM_VENDOR_FILTER + value: {{ . | join "," | quote }} + {{- end }} + {{- with .Values.pathFilter }} + - name: NDM_PATH_FILTER + value: {{ . | join "," | quote }} + {{- end }} + {{- with .Values.labelFilter }} + - name: NDM_LABEL_FILTER + value: {{ . | join "," | quote }} + {{- end }} + {{- with .Values.autoProvisionFilter }} + - name: NDM_AUTO_PROVISION_FILTER + value: {{ . | join "," | quote }} + {{- end }} + {{- with .Values.maxConcurrentOps }} + - name: NDM_MAX_CONCURRENT_OPS + value: {{ . | quote }} + {{- end }} + {{- with .Values.autoGPTGenerate }} + - name: NDM_AUTO_GPT_GENERATE + value: {{ . | quote }} + {{- end }} + - name: LONGHORN_NAMESPACE + value: {{ .Values.longhornNamespace | default "longhorn-system" }} + - name: NODE_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: spec.nodeName + securityContext: + privileged: true + volumeMounts: + - mountPath: /host/proc # To access dockerd/containerd mount namespace + name: host-proc + readOnly: true + - mountPath: /run/udev # To receive udev events + name: host-run-udev + readOnly: true + - mountPath: /dev # To get host device info + name: host-dev + readOnly: true + - mountPath: /sys # To get host sysfs info + name: host-sys + readOnly: true + 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 }} + volumes: + - name: host-proc + hostPath: + path: /proc + type: Directory + - name: host-run-udev + hostPath: + path: /run/udev + type: Directory + - name: host-dev + hostPath: + path: /dev + type: Directory + - name: host-sys + hostPath: + path: /sys + type: Directory diff --git a/charts/harvester-networkfs-manager/templates/rbac.yaml b/charts/harvester-networkfs-manager/templates/rbac.yaml new file mode 100644 index 000000000..ea519bce --- /dev/null +++ b/charts/harvester-networkfs-manager/templates/rbac.yaml @@ -0,0 +1,43 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "harvester-networkfs-manager.name" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "harvester-networkfs-manager.labels" . | nindent 4 }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "harvester-networkfs-manager.name" . }} +rules: + - apiGroups: [ "" ] + resources: [ "services", "endpoints", "persistentvolumes" ] + verbs: [ "get", "watch", "list" ] + - apiGroups: [ "harvesterhci.io" ] + resources: [ "networkfilesystems", "networkfilesystems/status" ] + verbs: [ "*" ] + - apiGroups: [ "coordination.k8s.io" ] + resources: [ "leases" ] + verbs: [ "*" ] + - apiGroups: [ "longhorn.io" ] + resources: [ "sharemanagers", "sharemanagers/status" ] + verbs: [ "get", "watch", "list" ] + - apiGroups: [ "longhorn.io" ] + resources: [ "volumeattachments", "volumeattachments/status" ] + verbs: [ "*" ] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "harvester-networkfs-manager.name" . }} + labels: + {{- include "harvester-networkfs-manager.labels" . | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "harvester-networkfs-manager.name" . }} +subjects: + - kind: ServiceAccount + name: {{ include "harvester-networkfs-manager.name" . }} + namespace: {{ .Release.Namespace }} diff --git a/charts/harvester-networkfs-manager/values.yaml b/charts/harvester-networkfs-manager/values.yaml new file mode 100644 index 000000000..27bab304 --- /dev/null +++ b/charts/harvester-networkfs-manager/values.yaml @@ -0,0 +1,44 @@ +# Default values for harvester-networkfs-manager. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +image: + repository: rancher/harvester-networkfs-manager + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "main-head" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podAnnotations: {} + +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: {} + +# Enable debug logging +debug: false