diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 22cd2c8..0000000 --- a/.drone.yml +++ /dev/null @@ -1,221 +0,0 @@ ---- -kind: pipeline -name: amd64 - -platform: - os: linux - arch: amd64 - -steps: -- name: build - image: rancher/dapper:v0.4.1 - commands: - - dapper ci - volumes: - - name: docker - path: /var/run/docker.sock - -- name: github_binary_release - image: plugins/github-release - settings: - api_key: - from_secret: github_token - prerelease: true - checksum: - - sha256 - checksum_file: CHECKSUMsum-amd64.txt - checksum_flatten: true - files: - - "dist/artifacts/*" - when: - instance: - - drone-publish.rancher.io - ref: - - refs/head/master - - refs/tags/* - event: - - tag - -- name: docker-publish - image: plugins/docker - settings: - dockerfile: package/Dockerfile - password: - from_secret: docker_password - repo: "galal-hussein/k3k" - tag: "${DRONE_TAG}-amd64" - username: - from_secret: docker_username - when: - instance: - - drone-publish.rancher.io - ref: - - refs/head/master - - refs/tags/* - event: - - tag - -volumes: -- name: docker - host: - path: /var/run/docker.sock - ---- -kind: pipeline -name: arm64 - -platform: - os: linux - arch: arm64 - -steps: -- name: build - image: rancher/dapper:v0.4.1 - commands: - - dapper ci - volumes: - - name: docker - path: /var/run/docker.sock - -- name: github_binary_release - image: plugins/github-release - settings: - api_key: - from_secret: github_token - prerelease: true - checksum: - - sha256 - checksum_file: CHECKSUMsum-arm64.txt - checksum_flatten: true - files: - - "dist/artifacts/*" - when: - instance: - - drone-publish.rancher.io - ref: - - refs/head/master - - refs/tags/* - event: - - tag - -- name: docker-publish - image: plugins/docker - settings: - dockerfile: package/Dockerfile - password: - from_secret: docker_password - repo: "galal-hussein/k3k" - tag: "${DRONE_TAG}-arm64" - username: - from_secret: docker_username - when: - instance: - - drone-publish.rancher.io - ref: - - refs/head/master - - refs/tags/* - event: - - tag - -volumes: -- name: docker - host: - path: /var/run/docker.sock - ---- -kind: pipeline -name: arm - -platform: - os: linux - arch: arm - -steps: -- name: build - image: rancher/dapper:v0.4.1 - commands: - - dapper ci - volumes: - - name: docker - path: /var/run/docker.sock - -- name: github_binary_release - image: plugins/github-release - settings: - api_key: - from_secret: github_token - prerelease: true - checksum: - - sha256 - checksum_file: CHECKSUMsum-arm.txt - checksum_flatten: true - files: - - "dist/artifacts/*" - when: - instance: - - drone-publish.rancher.io - ref: - - refs/head/master - - refs/tags/* - event: - - tag - -- name: docker-publish - image: plugins/docker - settings: - dockerfile: package/Dockerfile - password: - from_secret: docker_password - repo: "galal-hussein/k3k" - tag: "${DRONE_TAG}-arm" - username: - from_secret: docker_username - when: - instance: - - drone-publish.rancher.io - ref: - - refs/head/master - - refs/tags/* - event: - - tag - -volumes: -- name: docker - host: - path: /var/run/docker.sock - ---- -kind: pipeline -name: manifest - -platform: - os: linux - arch: amd64 - -steps: -- name: manifest - image: plugins/manifest:1.0.2 - settings: - username: - from_secret: docker_username - password: - from_secret: docker_password - platforms: - - linux/amd64 - - linux/arm64 - - linux/arm - target: "galal-hussein/k3k:${DRONE_TAG}" - template: "galal-hussein/k3k:${DRONE_TAG}-ARCH" - when: - instance: - - drone-publish.rancher.io - ref: - - refs/head/master - - refs/tags/* - event: - - tag - -depends_on: -- amd64 -- arm64 -- arm diff --git a/.gitignore b/.gitignore index 04ac636..d7d85cc 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,4 @@ /dist *.swp .idea -k3k diff --git a/charts/k3k/.helmignore b/charts/k3k/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/k3k/.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/k3k/Chart.yaml b/charts/k3k/Chart.yaml new file mode 100644 index 0000000..922e9f5 --- /dev/null +++ b/charts/k3k/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: k3k +description: A Helm chart for K3K +type: application +version: 0.1.0 +appVersion: 0.1.0 diff --git a/charts/k3k/templates/_helpers.tpl b/charts/k3k/templates/_helpers.tpl new file mode 100644 index 0000000..745ac4f --- /dev/null +++ b/charts/k3k/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "k3k.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 "k3k.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 "k3k.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "k3k.labels" -}} +helm.sh/chart: {{ include "k3k.chart" . }} +{{ include "k3k.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "k3k.selectorLabels" -}} +app.kubernetes.io/name: {{ include "k3k.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "k3k.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "k3k.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/k3k/templates/deployment.yaml b/charts/k3k/templates/deployment.yaml new file mode 100644 index 0000000..2395e29 --- /dev/null +++ b/charts/k3k/templates/deployment.yaml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "k3k.fullname" . }} + labels: + {{- include "k3k.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +spec: + replicas: {{ .Values.image.replicaCount }} + selector: + matchLabels: + {{- include "k3k.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "k3k.selectorLabels" . | nindent 8 }} + spec: + containers: + - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + name: {{ .Chart.Name }} + ports: + - containerPort: 8080 + name: https + protocol: TCP + livenessProbe: + httpGet: + path: / + port: https + readinessProbe: + httpGet: + path: / + port: https + serviceAccountName: {{ include "k3k.serviceAccountName" . }} \ No newline at end of file diff --git a/deploy/naemspace.yaml b/charts/k3k/templates/naemspace.yaml similarity index 56% rename from deploy/naemspace.yaml rename to charts/k3k/templates/naemspace.yaml index c2601d6..59f7944 100644 --- a/deploy/naemspace.yaml +++ b/charts/k3k/templates/naemspace.yaml @@ -1,4 +1,4 @@ apiVersion: v1 kind: Namespace metadata: - name: k3k-system \ No newline at end of file + name: {{ .Values.namespace }} \ No newline at end of file diff --git a/deploy/rbac.yaml b/charts/k3k/templates/rbac.yaml similarity index 52% rename from deploy/rbac.yaml rename to charts/k3k/templates/rbac.yaml index 1487be8..df583af 100644 --- a/deploy/rbac.yaml +++ b/charts/k3k/templates/rbac.yaml @@ -1,12 +1,14 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: k3k-admin + name: {{ include "k3k.fullname" . }} + labels: + {{- include "k3k.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount - name: k3k-serviceaccount - namespace: k3k-system \ No newline at end of file + name: {{ include "k3k.serviceAccountName" . }} + namespace: {{ .Values.namespace }} \ No newline at end of file diff --git a/charts/k3k/templates/serviceaccount.yaml b/charts/k3k/templates/serviceaccount.yaml new file mode 100644 index 0000000..30deaa0 --- /dev/null +++ b/charts/k3k/templates/serviceaccount.yaml @@ -0,0 +1,9 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "k3k.serviceAccountName" . }} + labels: + {{- include "k3k.labels" . | nindent 4 }} + namespace: {{ .Values.namespace }} +{{- end }} \ No newline at end of file diff --git a/charts/k3k/values.yaml b/charts/k3k/values.yaml new file mode 100644 index 0000000..1ab7468 --- /dev/null +++ b/charts/k3k/values.yaml @@ -0,0 +1,19 @@ +replicaCount: 1 +namespace: k3k-system + +image: + repository: husseingalal/k3k + 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 + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" \ No newline at end of file diff --git a/deploy/deployment.yaml b/deploy/deployment.yaml deleted file mode 100644 index 83587c7..0000000 --- a/deploy/deployment.yaml +++ /dev/null @@ -1,28 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: k3k-controller - namespace: k3k-system -spec: - replicas: 1 - selector: - matchLabels: - k8s-app: k3k-controller - template: - metadata: - labels: - k8s-app: k3k-controller - name: k3k-controller - spec: - containers: - - image: husseingalal/k3k:dev - imagePullPolicy: Always - name: k3k-controller - ports: - - containerPort: 8080 - name: https - protocol: TCP - restartPolicy: Always - schedulerName: default-scheduler - serviceAccount: k3k-serviceaccount - serviceAccountName: k3k-serviceaccount diff --git a/deploy/serviceaccount.yaml b/deploy/serviceaccount.yaml deleted file mode 100644 index 2be170b..0000000 --- a/deploy/serviceaccount.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - name: k3k-serviceaccount - namespace: k3k-system