Fix examples
This commit is contained in:
@@ -5,6 +5,6 @@ This is a basic example of what can do Katenary with standard docker-compose fil
|
|||||||
In this example:
|
In this example:
|
||||||
|
|
||||||
- `depends_on` yield a `initContainer` in the webapp ddeployment to wait for database
|
- `depends_on` yield a `initContainer` in the webapp ddeployment to wait for database
|
||||||
- so we need to declare the listened port inside `database` container as we don't use it with docker-compose- also, we needed to declare that `DB_HOST` is actually a service name
|
- so we need to declare the listened port inside `database` container as we don't use it with docker-compose- also, we needed to declare that `DB_HOST` is actually a service name using `mapenv` label
|
||||||
|
|
||||||
Take a look on [chart/basic](chart/basic) directory to see what `katenary convert` command has generated.
|
Take a look on [chart/basic](chart/basic) directory to see what `katenary convert` command has generated.
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
version: "3"
|
version: "3"
|
||||||
|
|
||||||
|
# this example is absolutely not working, it's an example to see how it is converted
|
||||||
|
# by Katenary
|
||||||
services:
|
services:
|
||||||
|
|
||||||
webapp:
|
webapp:
|
||||||
image: php:7-apache
|
image: php:7-apache
|
||||||
environment:
|
environment:
|
||||||
@@ -12,7 +13,8 @@ services:
|
|||||||
# expose an ingress
|
# expose an ingress
|
||||||
katenary.io/ingress: 80
|
katenary.io/ingress: 80
|
||||||
# DB_HOST is actually a service name
|
# DB_HOST is actually a service name
|
||||||
katenary.io/env-to-service: DB_HOST
|
katenary.io/mapenv: |
|
||||||
|
DB_HOST: {{ .Release.Name }}-database
|
||||||
depends_on:
|
depends_on:
|
||||||
- database
|
- database
|
||||||
|
|
||||||
|
9
examples/ghost/README.md
Normal file
9
examples/ghost/README.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Example with Ghost
|
||||||
|
|
||||||
|
[Ghost](https://ghost.org/) is a simple but powerfull blog engine. It is very nice to test some behaviors with Docker or Podman.
|
||||||
|
|
||||||
|
The given `docker-compose.yaml` file here declares a stand-alone blog service. To help using it, we use [Patwae](https://pathwae.net) reverse-proxy to listend http://ghost.example.localhost
|
||||||
|
|
||||||
|
The problem to solve is that the `url` environment variable correspond to the Ingress host when we will convert it to Helm Chart. So, we use the `mapenv` label to declare that `url` is actually `{{ .Values.blog.ingress.host }}` value.
|
||||||
|
|
||||||
|
Note that we also `ignore` pathwae because we don't need it in our Helm Chart.
|
8
examples/ghost/chart/ghost/Chart.yaml
Normal file
8
examples/ghost/chart/ghost/Chart.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Create on 2022-05-05T14:16:27+02:00
|
||||||
|
# Katenary command line: /tmp/go-build669507924/b001/exe/main convert
|
||||||
|
apiVersion: v2
|
||||||
|
appVersion: 0.0.1
|
||||||
|
description: A helm chart for ghost
|
||||||
|
name: ghost
|
||||||
|
type: application
|
||||||
|
version: 0.1.0
|
8
examples/ghost/chart/ghost/templates/NOTES.txt
Normal file
8
examples/ghost/chart/ghost/templates/NOTES.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
Congratulations,
|
||||||
|
|
||||||
|
Your application is now deployed. This may take a while to be up and responding.
|
||||||
|
|
||||||
|
{{ if .Values.blog.ingress.enabled -}}
|
||||||
|
- blog is accessible on : http://{{ .Values.blog.ingress.host }}
|
||||||
|
{{- end }}
|
33
examples/ghost/chart/ghost/templates/blog.deployment.yaml
Normal file
33
examples/ghost/chart/ghost/templates/blog.deployment.yaml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: '{{ .Release.Name }}-blog'
|
||||||
|
labels:
|
||||||
|
katenary.io/component: blog
|
||||||
|
katenary.io/project: ghost
|
||||||
|
katenary.io/release: '{{ .Release.Name }}'
|
||||||
|
annotations:
|
||||||
|
katenary.io/docker-compose-sha1: 0c2bbf548ff569c3dc5d77dc158e98bbe86fb5d4
|
||||||
|
katenary.io/version: master
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
katenary.io/component: blog
|
||||||
|
katenary.io/release: '{{ .Release.Name }}'
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
katenary.io/component: blog
|
||||||
|
katenary.io/release: '{{ .Release.Name }}'
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: blog
|
||||||
|
image: '{{ .Values.blog.image }}'
|
||||||
|
ports:
|
||||||
|
- name: blog
|
||||||
|
containerPort: 2368
|
||||||
|
env:
|
||||||
|
- name: url
|
||||||
|
value: http://{{ .Values.blog.ingress.host }}
|
||||||
|
|
42
examples/ghost/chart/ghost/templates/blog.ingress.yaml
Normal file
42
examples/ghost/chart/ghost/templates/blog.ingress.yaml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{{- if .Values.blog.ingress.enabled -}}
|
||||||
|
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||||
|
apiVersion: networking.k8s.io/v1beta1
|
||||||
|
{{- else -}}
|
||||||
|
apiVersion: extensions/v1beta1
|
||||||
|
{{- end }}
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: '{{ .Release.Name }}-blog'
|
||||||
|
labels:
|
||||||
|
katenary.io/component: blog
|
||||||
|
katenary.io/project: ghost
|
||||||
|
katenary.io/release: '{{ .Release.Name }}'
|
||||||
|
annotations:
|
||||||
|
katenary.io/docker-compose-sha1: 0c2bbf548ff569c3dc5d77dc158e98bbe86fb5d4
|
||||||
|
katenary.io/version: master
|
||||||
|
spec:
|
||||||
|
{{- if and .Values.blog.ingress.class (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
|
||||||
|
ingressClassName: '{{ .Values.blog.ingress.class }}'
|
||||||
|
{{- end }}
|
||||||
|
rules:
|
||||||
|
- host: '{{ .Values.blog.ingress.host }}'
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
{{- if semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion }}
|
||||||
|
pathType: Prefix
|
||||||
|
{{- end }}
|
||||||
|
backend:
|
||||||
|
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }}
|
||||||
|
service:
|
||||||
|
name: '{{ .Release.Name }}-blog'
|
||||||
|
port:
|
||||||
|
number: 2368
|
||||||
|
{{- else }}
|
||||||
|
serviceName: '{{ .Release.Name }}-blog'
|
||||||
|
servicePort: 2368
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- end -}}
|
19
examples/ghost/chart/ghost/templates/blog.service.yaml
Normal file
19
examples/ghost/chart/ghost/templates/blog.service.yaml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: '{{ .Release.Name }}-blog'
|
||||||
|
labels:
|
||||||
|
katenary.io/component: blog
|
||||||
|
katenary.io/project: ghost
|
||||||
|
katenary.io/release: '{{ .Release.Name }}'
|
||||||
|
annotations:
|
||||||
|
katenary.io/docker-compose-sha1: 0c2bbf548ff569c3dc5d77dc158e98bbe86fb5d4
|
||||||
|
katenary.io/version: master
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
katenary.io/component: blog
|
||||||
|
katenary.io/release: '{{ .Release.Name }}'
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 2368
|
||||||
|
targetPort: 2368
|
6
examples/ghost/chart/ghost/values.yaml
Normal file
6
examples/ghost/chart/ghost/values.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
blog:
|
||||||
|
image: ghost
|
||||||
|
ingress:
|
||||||
|
class: nginx
|
||||||
|
enabled: false
|
||||||
|
host: blog.ghost.tld
|
30
examples/ghost/docker-compose.yaml
Normal file
30
examples/ghost/docker-compose.yaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
blog:
|
||||||
|
image: ghost
|
||||||
|
environment:
|
||||||
|
# this is OK for local test, but not with Helm
|
||||||
|
# because the URL depends on Ingress
|
||||||
|
url: http://ghost.example.localhost
|
||||||
|
labels:
|
||||||
|
katenary.io/ports: 2368
|
||||||
|
katenary.io/ingress: 2368
|
||||||
|
# ... so we declare that "url" is actually
|
||||||
|
# the ingress host
|
||||||
|
katenary.io/mapenv: |
|
||||||
|
url: http://{{ .Values.blog.ingress.host }}
|
||||||
|
|
||||||
|
proxy:
|
||||||
|
# A simple proxy for localhost
|
||||||
|
image: quay.io/pathwae/proxy
|
||||||
|
environment:
|
||||||
|
CONFIG: |
|
||||||
|
ghost.example.localhost:
|
||||||
|
to: http://blog:2368
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
labels:
|
||||||
|
# we don't want this in Helm because we will use
|
||||||
|
# an ingress
|
||||||
|
katenary.io/ignore: true
|
Reference in New Issue
Block a user