diff --git a/README.md b/README.md index 2b38ca6..d3590ff 100644 --- a/README.md +++ b/README.md @@ -21,5 +21,6 @@ rsync -r $CHART_PATH/ charts/$APP/$VERSION touch charts/$APP/$VERSION/questions.yaml touch charts/$APP/item.yaml cp $APP_PATH/README.md charts/$APP/$VERSION +cp charts/$APP/$VERSION/README.md charts/$APP/$VERSION/app-readme.md cp charts/$APP/$VERSION/values.yaml charts/$APP/$VERSION/ix_values.yaml ``` diff --git a/charts/button/1.0.0/.helmignore b/charts/button/1.0.0/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/button/1.0.0/.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/button/1.0.0/Chart.yaml b/charts/button/1.0.0/Chart.yaml new file mode 100644 index 0000000..c19c2f4 --- /dev/null +++ b/charts/button/1.0.0/Chart.yaml @@ -0,0 +1,23 @@ +apiVersion: v2 +name: button +description: A Button Website for demonstrating Docker and 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: 1.0.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. +appVersion: 1.0.0 diff --git a/charts/button/1.0.0/README.md b/charts/button/1.0.0/README.md new file mode 100644 index 0000000..79903ef --- /dev/null +++ b/charts/button/1.0.0/README.md @@ -0,0 +1,55 @@ +# CI Builder + +My CI testing pipeline for a django project. + +[![pipeline status](https://gitlab.ducoterra.net/ducoterra/ci_builder/badges/master/pipeline.svg)](https://gitlab.ducoterra.net/ducoterra/ci_builder/-/commits/master) + +## Prereqs + +1. Docker: https://www.docker.com/products/docker-desktop +2. kubectl: https://kubernetes.io/docs/tasks/tools/#kubectl +3. helm: https://helm.sh/docs/intro/install/ +4. k3d: https://k3d.io/ +5. You'll be using "*.localhost" domains for testing. This means you'll either have to use Chrome (which has these built in) or firefox. In Firefox: + + 1. Type `about:config` in the url field of your browser and press enter + 2. Search for `network.dns.localDomains` + 3. Double click to edit the field + 4. Add these values: `button.localhost, pgadmin.localhost, traefik.localhost` + 5. As you build your own sites you can add more to test! + +## Docker + +```bash +# build the docker image. This uses the build step from docker-compose.yml. +docker compose build + +# Now start postgres, pgadmin and traefik +docker compose up -d postgres pgadmin traefik + +# Navigate to http://traefik.localhost to see your ingress routes + +# View the logs to check the container status +docker compose logs + +# Now start the init container and wait for migrations to apply +docker compose up init + +# Now start the button container +docker compose up -d button + +# View the site logs +docker compose logs --follow button + +# Navigate to http://button.localhost + +# Take down the site +docker compose down +``` + +## K3D + +```bash +# Create a cluster for our button app +k3d cluster create button -p "80:8000@loadbalancer" --volume $HOME/.kube/registries.yaml:/var/lib/rancher/k3s/registries.yaml +``` diff --git a/charts/button/1.0.0/app-readme.md b/charts/button/1.0.0/app-readme.md new file mode 100644 index 0000000..79903ef --- /dev/null +++ b/charts/button/1.0.0/app-readme.md @@ -0,0 +1,55 @@ +# CI Builder + +My CI testing pipeline for a django project. + +[![pipeline status](https://gitlab.ducoterra.net/ducoterra/ci_builder/badges/master/pipeline.svg)](https://gitlab.ducoterra.net/ducoterra/ci_builder/-/commits/master) + +## Prereqs + +1. Docker: https://www.docker.com/products/docker-desktop +2. kubectl: https://kubernetes.io/docs/tasks/tools/#kubectl +3. helm: https://helm.sh/docs/intro/install/ +4. k3d: https://k3d.io/ +5. You'll be using "*.localhost" domains for testing. This means you'll either have to use Chrome (which has these built in) or firefox. In Firefox: + + 1. Type `about:config` in the url field of your browser and press enter + 2. Search for `network.dns.localDomains` + 3. Double click to edit the field + 4. Add these values: `button.localhost, pgadmin.localhost, traefik.localhost` + 5. As you build your own sites you can add more to test! + +## Docker + +```bash +# build the docker image. This uses the build step from docker-compose.yml. +docker compose build + +# Now start postgres, pgadmin and traefik +docker compose up -d postgres pgadmin traefik + +# Navigate to http://traefik.localhost to see your ingress routes + +# View the logs to check the container status +docker compose logs + +# Now start the init container and wait for migrations to apply +docker compose up init + +# Now start the button container +docker compose up -d button + +# View the site logs +docker compose logs --follow button + +# Navigate to http://button.localhost + +# Take down the site +docker compose down +``` + +## K3D + +```bash +# Create a cluster for our button app +k3d cluster create button -p "80:8000@loadbalancer" --volume $HOME/.kube/registries.yaml:/var/lib/rancher/k3s/registries.yaml +``` diff --git a/charts/button/1.0.0/ix_values.yaml b/charts/button/1.0.0/ix_values.yaml new file mode 100644 index 0000000..5a8d84e --- /dev/null +++ b/charts/button/1.0.0/ix_values.yaml @@ -0,0 +1,3 @@ +image: ducoterra/button +tag: 1.0.2 +secret: true diff --git a/charts/button/1.0.0/questions.yaml b/charts/button/1.0.0/questions.yaml new file mode 100644 index 0000000..1e7c754 --- /dev/null +++ b/charts/button/1.0.0/questions.yaml @@ -0,0 +1,12 @@ +groups: + - name: "Let's Encrypt Config" + description: "Let's Encrypt configuration details for cert-manager" + - name: "Nginx Config" + description: "Nginx configuration details" +questions: + - variable: email + description: "Let's Encrypt Email" + group: "Let's Encrypt Config" + label: "Let's Encrypt Email" + schema: + type: string diff --git a/charts/button/1.0.0/templates/configmap.yaml b/charts/button/1.0.0/templates/configmap.yaml new file mode 100644 index 0000000..3fb1193 --- /dev/null +++ b/charts/button/1.0.0/templates/configmap.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }} + labels: + app: {{ .Release.Name }} +data: + ALLOWED_HOSTS: {{ .Release.Name }}.ducoterra.net diff --git a/charts/button/1.0.0/templates/deploy.yaml b/charts/button/1.0.0/templates/deploy.yaml new file mode 100644 index 0000000..0e9ec82 --- /dev/null +++ b/charts/button/1.0.0/templates/deploy.yaml @@ -0,0 +1,33 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }} + spec: + containers: + - image: {{ required "A valid .Values.image entry required!" .Values.image }}:{{ required "A valid .Values.tag entry required!" .Values.tag }} + name: {{ .Release.Name }} + ports: + - containerPort: 8080 + envFrom: + - configMapRef: + name: {{ .Release.Name }} + - secretRef: + name: {{ .Release.Name }} + - secretRef: + name: postgres + resources: + limits: + memory: "500Mi" + cpu: "250m" + requests: + memory: "1Mi" + cpu: "100m" diff --git a/charts/button/1.0.0/templates/hpa.yaml b/charts/button/1.0.0/templates/hpa.yaml new file mode 100644 index 0000000..dcdd97c --- /dev/null +++ b/charts/button/1.0.0/templates/hpa.yaml @@ -0,0 +1,18 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ .Release.Name }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Release.Name }} + minReplicas: 1 + maxReplicas: 4 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 \ No newline at end of file diff --git a/charts/button/1.0.0/templates/ingress.yaml b/charts/button/1.0.0/templates/ingress.yaml new file mode 100755 index 0000000..58f6d1f --- /dev/null +++ b/charts/button/1.0.0/templates/ingress.yaml @@ -0,0 +1,23 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + cert-manager.io/cluster-issuer: letsencrypt-prod + kubernetes.io/ingress.class: nginx + name: {{ .Release.Name }} +spec: + rules: + - host: {{ .Release.Name }}.freenas.dnet + http: + paths: + - backend: + service: + name: {{ .Release.Name }} + port: + number: 8000 + path: / + pathType: Prefix + # tls: + # - hosts: + # - {{ .Release.Name }}.ducoterra.net + # secretName: {{.Release.Name}}-tls-cert diff --git a/charts/button/1.0.0/templates/secret.yaml b/charts/button/1.0.0/templates/secret.yaml new file mode 100644 index 0000000..434418d --- /dev/null +++ b/charts/button/1.0.0/templates/secret.yaml @@ -0,0 +1,10 @@ +{{ if and .Values.secret .Release.IsInstall }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Release.Name }} +type: generic +data: + SECRET_KEY: {{ randAlphaNum 64 | b64enc | quote }} + DJANGO_SUPERUSER_PASSWORD: {{ randAlphaNum 64 | b64enc | quote }} +{{ end }} \ No newline at end of file diff --git a/charts/button/1.0.0/templates/service.yaml b/charts/button/1.0.0/templates/service.yaml new file mode 100644 index 0000000..48cd3d3 --- /dev/null +++ b/charts/button/1.0.0/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: {{ .Release.Name }} + name: {{ .Release.Name }} +spec: + ports: + - port: 8000 + protocol: TCP + name: {{ .Release.Name }}-web + targetPort: 8000 + selector: + app: {{ .Release.Name }} # This selects the pod(s) that match the selector + type: ClusterIP \ No newline at end of file diff --git a/charts/button/1.0.0/values.yaml b/charts/button/1.0.0/values.yaml new file mode 100644 index 0000000..5a8d84e --- /dev/null +++ b/charts/button/1.0.0/values.yaml @@ -0,0 +1,3 @@ +image: ducoterra/button +tag: 1.0.2 +secret: true diff --git a/charts/button/item.yaml b/charts/button/item.yaml new file mode 100644 index 0000000..8e9feaf --- /dev/null +++ b/charts/button/item.yaml @@ -0,0 +1,3 @@ +categories: + - generic +icon_url: "http://ix_url"