Add button app to charts

Add button app to test ingress-nginx
This commit is contained in:
ducoterra
2021-08-28 18:01:24 -04:00
parent 1027a45a0c
commit 120c97a07d
15 changed files with 285 additions and 0 deletions

View File

@@ -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
```

View File

@@ -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/

View File

@@ -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

View File

@@ -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
```

View File

@@ -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
```

View File

@@ -0,0 +1,3 @@
image: ducoterra/button
tag: 1.0.2
secret: true

View File

@@ -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

View File

@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}
labels:
app: {{ .Release.Name }}
data:
ALLOWED_HOSTS: {{ .Release.Name }}.ducoterra.net

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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 }}

View File

@@ -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

View File

@@ -0,0 +1,3 @@
image: ducoterra/button
tag: 1.0.2
secret: true

3
charts/button/item.yaml Normal file
View File

@@ -0,0 +1,3 @@
categories:
- generic
icon_url: "http://ix_url"