diff --git a/examples/example.BucketAccess.yaml b/examples/example.BucketAccess.yaml new file mode 100644 index 0000000..6e7efa5 --- /dev/null +++ b/examples/example.BucketAccess.yaml @@ -0,0 +1,10 @@ +apiVersion: objectstorage.k8s.io/v1alpha1 +kind: BucketAccess +metadata: + name: example-access + namespace: default +spec: + bucketClaimName: example-claim + protocol: S3 + bucketAccessClassName: example-accessclass + credentialsSecretName: example-secret diff --git a/examples/example.BucketAccessClass.yaml b/examples/example.BucketAccessClass.yaml new file mode 100644 index 0000000..2faba47 --- /dev/null +++ b/examples/example.BucketAccessClass.yaml @@ -0,0 +1,8 @@ +apiVersion: objectstorage.k8s.io/v1alpha1 +kind: BucketAccessClass +metadata: + name: example-accessclass +driverName: objectstorage.cosi.linode.com +authenticationType: Key +parameters: + permissions: Read/Write # ReadOnly diff --git a/examples/example.BucketClaim.yaml b/examples/example.BucketClaim.yaml new file mode 100644 index 0000000..99f4d12 --- /dev/null +++ b/examples/example.BucketClaim.yaml @@ -0,0 +1,8 @@ +apiVersion: objectstorage.k8s.io/v1alpha1 +kind: BucketClaim +metadata: + name: example-claim + namespace: default +spec: + bucketClassName: example-class + protocols: [ 'S3' ] diff --git a/examples/example.BucketClass.yaml b/examples/example.BucketClass.yaml new file mode 100644 index 0000000..2821fdd --- /dev/null +++ b/examples/example.BucketClass.yaml @@ -0,0 +1,8 @@ +apiVersion: objectstorage.k8s.io/v1alpha1 +kind: BucketClass +metadata: + name: my-bucketclass +driverName: objectstorage.cosi.linode.com +deletionPolicy: Delete +parameters: + region: us-east diff --git a/helm/.kube-linter.yaml b/helm/.kube-linter.yaml new file mode 100644 index 0000000..8c3bd3c --- /dev/null +++ b/helm/.kube-linter.yaml @@ -0,0 +1,70 @@ +checks: + include: + - "access-to-create-pods" + # - "access-to-secrets" + - "cluster-admin-role-binding" + - "dangling-horizontalpodautoscaler" + - "dangling-ingress" + - "dangling-networkpolicy" + - "dangling-networkpolicypeer-podselector" + - "dangling-service" + - "default-service-account" + - "deprecated-service-account-field" + # - "dnsconfig-options" + - "docker-sock" + - "drop-net-raw-capability" + - "duplicate-env-var" + - "env-var-secret" + - "exposed-services" + - "host-ipc" + - "host-network" + - "host-pid" + - "hpa-minimum-three-replicas" + - "invalid-target-ports" + - "latest-tag" + # - "minimum-three-replicas" + - "mismatching-selector" + - "no-anti-affinity" + - "no-extensions-v1beta" + # - "no-liveness-probe" + # - "no-node-affinity" + - "no-read-only-root-fs" + # - "no-readiness-probe" + # - "no-rolling-update-strategy" + - "non-existent-service-account" + # - "non-isolated-pod" + - "privilege-escalation-container" + - "privileged-container" + - "privileged-ports" + - "read-secret-from-env-var" + # - "required-annotation-email" + # - "required-label-owner" + - "run-as-non-root" + - "sensitive-host-mounts" + - "ssh-port" + - "unsafe-proc-mount" + - "unsafe-sysctls" + # - "unset-cpu-requirements" + # - "unset-memory-requirements" + # - "use-namespace" + - "wildcard-in-rules" + - "writable-host-mount" + + # NOTE: manually exclude failing for documentation, fix them in future or + # comment why are they disabled. + exclude: + - "access-to-secrets" # NOTE: COSI Provisioner Sidecar requires access to secrets + - "dnsconfig-options" + - "minimum-three-replicas" + - "no-liveness-probe" + - "no-node-affinity" + - "no-readiness-probe" + - "no-rolling-update-strategy" + - "non-isolated-pod" + - "pdb-max-unavailable" + - "pdb-min-available" + - "required-annotation-email" + - "required-label-owner" + - "unset-cpu-requirements" + - "unset-memory-requirements" + - "use-namespace" diff --git a/helm/linode-cosi-driver/.helmignore b/helm/linode-cosi-driver/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm/linode-cosi-driver/.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/helm/linode-cosi-driver/Chart.yaml b/helm/linode-cosi-driver/Chart.yaml new file mode 100644 index 0000000..1a517cb --- /dev/null +++ b/helm/linode-cosi-driver/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: linode-cosi-driver +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: "v0.1.0" diff --git a/helm/linode-cosi-driver/README.md b/helm/linode-cosi-driver/README.md new file mode 100644 index 0000000..a4b9b03 --- /dev/null +++ b/helm/linode-cosi-driver/README.md @@ -0,0 +1,47 @@ +# linode-cosi-driver + +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.16.0](https://img.shields.io/badge/AppVersion-1.16.0-informational?style=flat-square) + +A Helm chart for Kubernetes + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | | +| autoscaling.enabled | bool | `false` | | +| autoscaling.maxReplicas | int | `100` | | +| autoscaling.minReplicas | int | `1` | | +| autoscaling.targetCPUUtilizationPercentage | int | `80` | | +| fullnameOverride | string | `""` | | +| image.pullPolicy | string | `"IfNotPresent"` | | +| image.repository | string | `"nginx"` | | +| image.tag | string | `""` | | +| imagePullSecrets | list | `[]` | | +| ingress.annotations | object | `{}` | | +| ingress.className | string | `""` | | +| ingress.enabled | bool | `false` | | +| ingress.hosts[0].host | string | `"chart-example.local"` | | +| ingress.hosts[0].paths[0].path | string | `"/"` | | +| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | | +| ingress.tls | list | `[]` | | +| nameOverride | string | `""` | | +| nodeSelector | object | `{}` | | +| podAnnotations | object | `{}` | | +| podLabels | object | `{}` | | +| podSecurityContext | object | `{}` | | +| replicaCount | int | `1` | | +| resources | object | `{}` | | +| securityContext | object | `{}` | | +| service.port | int | `80` | | +| service.type | string | `"ClusterIP"` | | +| serviceAccount.annotations | object | `{}` | | +| serviceAccount.automount | bool | `true` | | +| serviceAccount.create | bool | `true` | | +| serviceAccount.name | string | `""` | | +| tolerations | list | `[]` | | +| volumeMounts | list | `[]` | | +| volumes | list | `[]` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.11.3](https://github.com/norwoodj/helm-docs/releases/v1.11.3) diff --git a/helm/linode-cosi-driver/templates/NOTES.txt b/helm/linode-cosi-driver/templates/NOTES.txt new file mode 100644 index 0000000..eab4996 --- /dev/null +++ b/helm/linode-cosi-driver/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "linode-cosi-driver.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 "linode-cosi-driver.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "linode-cosi-driver.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "linode-cosi-driver.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 }} diff --git a/helm/linode-cosi-driver/templates/_helpers.tpl b/helm/linode-cosi-driver/templates/_helpers.tpl new file mode 100644 index 0000000..6968ba8 --- /dev/null +++ b/helm/linode-cosi-driver/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "linode-cosi-driver.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 "linode-cosi-driver.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 "linode-cosi-driver.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "linode-cosi-driver.labels" -}} +helm.sh/chart: {{ include "linode-cosi-driver.chart" . }} +{{ include "linode-cosi-driver.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "linode-cosi-driver.selectorLabels" -}} +app.kubernetes.io/name: {{ include "linode-cosi-driver.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "linode-cosi-driver.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "linode-cosi-driver.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm/linode-cosi-driver/templates/tests/.gitkeep b/helm/linode-cosi-driver/templates/tests/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/helm/linode-cosi-driver/values.yaml b/helm/linode-cosi-driver/values.yaml new file mode 100644 index 0000000..434698d --- /dev/null +++ b/helm/linode-cosi-driver/values.yaml @@ -0,0 +1,98 @@ +# Default values for linode-cosi-driver. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: nginx + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: 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: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +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 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {}