parent
cc4589cb14
commit
10ad216fcf
7 changed files with 41 additions and 10 deletions
15
chart/templates/_helpers.tpl
Normal file
15
chart/templates/_helpers.tpl
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Expand the name of the chart.
|
||||||
|
*/}}
|
||||||
|
{{ define "testapp.name" }}{{ default "testapp" .Values.nameOverride | trunc 63 }}{{ 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).
|
||||||
|
*/}}
|
||||||
|
{{ define "testapp.fullname" }}
|
||||||
|
{{- $name := default "testapp" .Values.nameOverride -}}
|
||||||
|
{{ printf "%s-%s" .Release.Name $name | trunc 63 -}}
|
||||||
|
{{ end }}
|
||||||
|
|
@ -10,6 +10,11 @@ metadata:
|
||||||
component: db
|
component: db
|
||||||
spec:
|
spec:
|
||||||
replicas: {{ .Values.db.replicas }}
|
replicas: {{ .Values.db.replicas }}
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: {{ template "testapp.name" . }}-db
|
||||||
|
release: "{{ .Release.Name }}"
|
||||||
|
component: db
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,11 @@ metadata:
|
||||||
component: srv
|
component: srv
|
||||||
spec:
|
spec:
|
||||||
replicas: {{ .Values.srv.replicas }}
|
replicas: {{ .Values.srv.replicas }}
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: {{ template "testapp.name" . }}-srv
|
||||||
|
release: "{{ .Release.Name }}"
|
||||||
|
component: srv
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
|
|
@ -42,7 +47,7 @@ spec:
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
env:
|
env:
|
||||||
- name: DB_HOST
|
- name: DB_HOST
|
||||||
value: {{ template "testapp.fullname" . }}-db.{{ Release.Namespace }}.svc
|
value: {{ template "testapp.fullname" . }}-db.{{ .Release.Namespace }}.svc
|
||||||
{{- range $key, $value := .Values.srv.env }}
|
{{- range $key, $value := .Values.srv.env }}
|
||||||
- name: {{ $key }}
|
- name: {{ $key }}
|
||||||
value: {{ $value | quote }}
|
value: {{ $value | quote }}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,25 @@
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ template "drone.fullname" . }}-db
|
name: {{ template "testapp.fullname" . }}-db
|
||||||
annotations:
|
annotations:
|
||||||
{{- range $key, $value := .Values.Db.service.annotations }}
|
{{- range $key, $value := .Values.service.db.annotations }}
|
||||||
{{ $key }}: {{ $value | quote }}
|
{{ $key }}: {{ $value | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
labels:
|
labels:
|
||||||
app: {{ template "drone.name" . }}-db
|
app: {{ template "testapp.name" . }}-db
|
||||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
||||||
release: "{{ .Release.Name }}"
|
release: "{{ .Release.Name }}"
|
||||||
heritage: "{{ .Release.Service }}"
|
heritage: "{{ .Release.Service }}"
|
||||||
spec:
|
spec:
|
||||||
type: {{ .Values.Db.service.type }}
|
type: {{ .Values.service.db.type }}
|
||||||
ports:
|
ports:
|
||||||
- name: http
|
- name: http
|
||||||
port: {{ .Values.Db.service.httpPort }}
|
port: {{ .Values.service.db.httpPort }}
|
||||||
targetPort: 8080
|
targetPort: 8080
|
||||||
{{- if hasKey .Values.Db.service "nodePort" }}
|
{{- if hasKey .Values.service.db "nodePort" }}
|
||||||
nodePort: {{ .Values.Db.service.nodePort }}
|
nodePort: {{ .Values.service.db.nodePort }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
selector:
|
selector:
|
||||||
app: {{ template "drone.name" . }}-db
|
app: {{ template "testapp.name" . }}-db
|
||||||
release: {{ .Release.Name | quote }}
|
release: {{ .Release.Name | quote }}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ metadata:
|
||||||
host: "^{{ .Values.srv.host }}.*$"
|
host: "^{{ .Values.srv.host }}.*$"
|
||||||
host_regex: true
|
host_regex: true
|
||||||
prefix: /
|
prefix: /
|
||||||
service: {{ template "testapp.fullname" . }}-srv.{{ Release.Namespace }}.svc:8080
|
service: {{ template "testapp.fullname" . }}-srv.{{ .Release.Namespace }}.svc:8080
|
||||||
{{- range $key, $value := .Values.service.srv.annotations }}
|
{{- range $key, $value := .Values.service.srv.annotations }}
|
||||||
{{ $key }}: {{ $value | quote }}
|
{{ $key }}: {{ $value | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
||||||
3
db.go
3
db.go
|
|
@ -11,6 +11,9 @@ import (
|
||||||
var version string
|
var version string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
})
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL)
|
log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL)
|
||||||
h, err := os.Hostname()
|
h, err := os.Hostname()
|
||||||
|
|
|
||||||
3
srv.go
3
srv.go
|
|
@ -15,6 +15,9 @@ import (
|
||||||
var version string
|
var version string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
})
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL)
|
log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL)
|
||||||
h, err := os.Hostname()
|
h, err := os.Hostname()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue