diff --git a/.woodpecker/fleetlock.yaml b/.woodpecker/fleetlock.yaml new file mode 100644 index 0000000..402cf82 --- /dev/null +++ b/.woodpecker/fleetlock.yaml @@ -0,0 +1,13 @@ +--- +when: + path: "charts/fleetlock/**" +branches: + - main +pipeline: + package: + image: "docker.io/alpine/helm:latest" + secrets: [helm_user, helm_password, helm_repo] + commands: + - helm plugin install https://github.com/chartmuseum/helm-push + - helm repo add therepo $HELM_REPO --username $HELM_USER --password $HELM_PASSWORD + - helm cm-push charts/fleetlock therepo diff --git a/charts/fleetlock/.helmignore b/charts/fleetlock/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/fleetlock/.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/fleetlock/Chart.yaml b/charts/fleetlock/Chart.yaml new file mode 100644 index 0000000..f3523b8 --- /dev/null +++ b/charts/fleetlock/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: fleetlock +description: A Helm chart for fleetlock. +type: application +version: 0.1.0 +appVersion: "v0.4.0" diff --git a/charts/fleetlock/templates/_helpers.tpl b/charts/fleetlock/templates/_helpers.tpl new file mode 100644 index 0000000..8f4a8b6 --- /dev/null +++ b/charts/fleetlock/templates/_helpers.tpl @@ -0,0 +1,58 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "fleetlock.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 "fleetlock.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 "fleetlock.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "fleetlock.labels" -}} +helm.sh/chart: {{ include "fleetlock.chart" . }} +{{ include "fleetlock.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "fleetlock.selectorLabels" -}} +app.kubernetes.io/name: {{ include "fleetlock.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "fleetlock.serviceAccountName" -}} +{{- default (include "fleetlock.fullname" .) .Values.serviceAccount.name }} +{{- end }} diff --git a/charts/fleetlock/templates/cluster-role-binding.yaml b/charts/fleetlock/templates/cluster-role-binding.yaml new file mode 100644 index 0000000..4dc0693 --- /dev/null +++ b/charts/fleetlock/templates/cluster-role-binding.yaml @@ -0,0 +1,14 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "fleetlock.fullname" . }} + labels: + {{- include "fleetlock.labels" . | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "fleetlock.fullname" . }} +subjects: +- kind: ServiceAccount + name: {{ include "fleetlock.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} diff --git a/charts/fleetlock/templates/cluster-role.yaml b/charts/fleetlock/templates/cluster-role.yaml new file mode 100644 index 0000000..47c592f --- /dev/null +++ b/charts/fleetlock/templates/cluster-role.yaml @@ -0,0 +1,26 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "fleetlock.fullname" . }} + labels: + {{- include "fleetlock.labels" . | nindent 4 }} +rules: + - apiGroups: + - "" + resources: + - nodes + verbs: + - list + - patch + - apiGroups: + - "" + resources: + - pods + verbs: + - list + - apiGroups: + - "" + resources: + - pods/eviction + verbs: + - create diff --git a/charts/fleetlock/templates/deployment.yaml b/charts/fleetlock/templates/deployment.yaml new file mode 100644 index 0000000..c3f365c --- /dev/null +++ b/charts/fleetlock/templates/deployment.yaml @@ -0,0 +1,61 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "fleetlock.fullname" . }} + labels: + {{- include "fleetlock.labels" . | nindent 4 }} +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + {{- include "fleetlock.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "fleetlock.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "fleetlock.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 }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + scheme: HTTP + port: 8080 + path: /-/healthy + resources: + {{- toYaml .Values.resources | nindent 12 }} + env: + - name: NAMESPACE + value: {{ .Release.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/fleetlock/templates/role-binding.yaml b/charts/fleetlock/templates/role-binding.yaml new file mode 100644 index 0000000..55d2c2b --- /dev/null +++ b/charts/fleetlock/templates/role-binding.yaml @@ -0,0 +1,14 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ include "fleetlock.fullname" . }} + labels: + {{- include "fleetlock.labels" . | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ include "fleetlock.fullname" . }} +subjects: +- kind: ServiceAccount + name: {{ include "fleetlock.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} diff --git a/charts/fleetlock/templates/role.yaml b/charts/fleetlock/templates/role.yaml new file mode 100644 index 0000000..283d25e --- /dev/null +++ b/charts/fleetlock/templates/role.yaml @@ -0,0 +1,14 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: fleetlock +rules: + - apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - create + - get + - update + diff --git a/charts/fleetlock/templates/service-account.yaml b/charts/fleetlock/templates/service-account.yaml new file mode 100644 index 0000000..98feee0 --- /dev/null +++ b/charts/fleetlock/templates/service-account.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "fleetlock.serviceAccountName" . }} + labels: + {{- include "fleetlock.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} diff --git a/charts/fleetlock/templates/service.yaml b/charts/fleetlock/templates/service.yaml new file mode 100644 index 0000000..2a63ac2 --- /dev/null +++ b/charts/fleetlock/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "fleetlock.fullname" . }} + labels: + {{- include "fleetlock.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "fleetlock.selectorLabels" . | nindent 4 }} diff --git a/charts/fleetlock/values.yaml b/charts/fleetlock/values.yaml new file mode 100644 index 0000000..33dc772 --- /dev/null +++ b/charts/fleetlock/values.yaml @@ -0,0 +1,53 @@ +# Default values for fleetlock. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: quay.io/poseidon/fleetlock + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # 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 + port: 30973 + +resources: + limits: + cpu: 50m + memory: 50Mi + requests: + cpu: 50m + memory: 50Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {}