"Adopting to https://github.com/kubernetes/charts format per bacongobbler"

pull/3201/head
Yahav Biran 8 years ago
parent 03d8ed11f0
commit 1586f26ade

@ -1,9 +1,4 @@
apiVersion: v1
description: A guestbook Helm chart for Kubernetes.
name: guestbook
version: 0.1.0
description: Guestbook Helm chart for Kubernetes.
sources:
- https://github.com/kubernetes/kubernetes/tree/master/examples/guestbook
maintainers:
- name: Yahav Biran
- email: ybiran@colostate.edu

@ -0,0 +1,68 @@
# Guestbook
[Guestbook](https://github.com/kubernetes/examples/tree/master/guestbook) is a simple, multi-tier PHP-based web application that uses redis chart.
## TL;DR;
```console
$ helm install stable/guestbook
```
## Introduction
This chart bootstraps a [guestbook](https://github.com/kubernetes/examples/tree/master/guestbook) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
It also packages the [Bitnami Redis chart](https://github.com/kubernetes/charts/tree/master/stable/redis) which is required for bootstrapping a Redis deployment for the caching requirements of the guestbook application.
## Prerequisites
- Kubernetes 1.4+ with Beta APIs enabled
- PV provisioner support in the underlying infrastructure
## Installing the Chart
To install the chart with the release name `my-release`:
```console
$ helm install --name my-release stable/guestbook
```
The command deploys the guestbook on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.
> **Tip**: List all releases using `helm list`
## Uninstalling the Chart
To uninstall/delete the `my-release` deployment:
```console
$ helm delete my-release
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration
The following tables lists the configurable parameters of the WordPress chart and their default values.
| Parameter | Description | Default |
| ------------------------------- | ------------------------------- | ---------------------------------------------------------- |
| `image` | apapche-php image | `google-samples/gb-frontend:{VERSION}` |
| `imagePullPolicy` | Image pull policy | `IfNotPresent` |
| `nodeSelector` | Node labels for pod assignment | `{}` |
The above parameters map to the env variables defined in [bitnami/wordpress](http://github.com/bitnami/bitnami-docker-wordpress). For more information please refer to the [bitnami/wordpress](http://github.com/bitnami/bitnami-docker-wordpress) image documentation.
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```console
$ helm install --name my-release \
--set redis.usePassword=false \
stable/guestbook
```
```console
$ helm install --name my-release -f values.yaml stable/guestbook
```
> **Tip**: You can use the default [values.yaml](values.yaml)

@ -0,0 +1,6 @@
dependencies:
- name: redis
repository: https://kubernetes-charts.storage.googleapis.com/
version: 1.1.4
digest: sha256:ca7a601363b96fed2bf4774ef8fbc5cdbdb91a0fb5bc083192072e39eee844ae
generated: 2017-12-31T21:26:54.89952-08:00

@ -0,0 +1,7 @@
dependencies:
- name: redis
version: 1.1.4
repository: https://kubernetes-charts.storage.googleapis.com/
condition: redis.enabled
tags:
- redis-database

@ -4,14 +4,16 @@
http://{{ . }}
{{- end }}
{{- else if contains "NodePort" .Values.service.frontend.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "gbhelm.fullname" . }})
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "guestbook.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.frontend.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ template "gbhelm.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "gbhelm.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
You can watch the status of by running 'kubectl get svc -w {{ template "guestbook.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "guestbook.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
{{- else if contains "ClusterIP" .Values.service.frontend.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "gbhelm.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "guestbook.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:{{ .Values.service.internalPort }}
{{- end }}

@ -2,7 +2,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "gbhelm.name" -}}
{{- define "guestbook.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
@ -10,7 +10,10 @@ Expand the name of the chart.
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 "gbhelm.fullname" -}}
{{- define "guestbook.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- define "redis.fullname" -}}
{{- printf "%s-%s" .Release.Name "redis" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

@ -0,0 +1,52 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "guestbook.fullname" . }}
labels:
app: {{ template "guestbook.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
app: {{ template "guestbook.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.frontend.internalPort }}
livenessProbe:
httpGet:
path: /
port: {{ .Values.service.frontend.internalPort }}
readinessProbe:
httpGet:
path: /
port: {{ .Values.service.frontend.internalPort }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
env:
- name: {{"GET_HOSTS_FROM"}}
value: {{"env"}}
- name: {{"REDIS_MASTER_SERVICE_HOST"}}
{{- if .Values.redis.enabled }}
value: {{ template "redis.fullname" . }}
{{- else }}
value: {{ .Values.externalDatabase.host | quote }}
{{- end }}
- name: {{"REDIS_SLAVE_SERVICE_HOST"}}
{{- if .Values.redis.enabled }}
value: {{ template "redis.fullname" . }}
{{- else }}
value: {{ .Values.externalDatabase.host | quote }}
{{- end }}

@ -1,39 +0,0 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ "frontend" }}
labels:
app: {{ template "gbhelm.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ "1" }}
template:
metadata:
labels:
app: {{ "guestbook" }}
tier: {{"frontend"}}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ "php-redis" }}
image: "{{ .Values.image.frontend_deployment.repository }}:{{ .Values.image.frontend_deployment.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.frontend.port }}
livenessProbe:
httpGet:
path: /
port: {{ .Values.service.frontend.port }}
readinessProbe:
httpGet:
path: /
port: {{ .Values.service.frontend.port }}
resources:
requests:
cpu: {{"100m"}}
memory: {{"100Mi"}}
env:
- name: {{"GET_HOSTS_FROM"}}
value: {{"dns"}}

@ -1,17 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: {{ "frontend" }}
labels:
app: {{ "guestbook" }}
tier: {{ "frontend" }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.frontend.type }}
ports:
- port: {{.Values.service.frontend.port}}
selector:
app: {{.Values.service.frontend.selector.app}}
tier: {{.Values.service.frontend.selector.tier}}

@ -0,0 +1,32 @@
{{- if .Values.ingress.enabled -}}
{{- $serviceName := include "guestbook.fullname" . -}}
{{- $servicePort := .Values.service.externalPort -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "guestbook.fullname" . }}
labels:
app: {{ template "guestbook.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
rules:
{{- range $host := .Values.ingress.hosts }}
- host: {{ $host }}
http:
paths:
- path: /
backend:
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end -}}
{{- end -}}

@ -1,29 +0,0 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ "redis-master" }}
labels:
app: {{ template "gbhelm.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ "1" }}
template:
metadata:
labels:
app: {{ "redis" }}
tier: {{"backend"}}
role: {{"master"}}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ "master" }}
image: "{{ .Values.image.redis_master.repository }}:{{ .Values.image.redis_master.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ "6379" }}
resources:
requests:
cpu: {{"100m"}}
memory: {{"100Mi"}}

@ -1,19 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: {{ "redis-master" }}
labels:
app: {{ "redis" }}
role: {{ "master" }}
tier: {{ "backend" }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
ports:
- port: {{ .Values.service.redis_master.port }}
targetPort: {{ .Values.service.redis_master.targetPort }}
selector:
app: {{ .Values.service.redis_master.selector.app}}
role: {{ .Values.service.redis_master.selector.role }}
tier: {{ .Values.service.redis_master.selector.tier }}

@ -1,32 +0,0 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ "redis-slave" }}
labels:
app: {{ template "gbhelm.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ "1" }}
template:
metadata:
labels:
app: {{ "redis" }}
tier: {{"backend"}}
role: {{"slave"}}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ "slave" }}
image: "{{ .Values.image.redis_slave.repository }}:{{ .Values.image.redis_slave.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ "6379" }}
resources:
requests:
cpu: {{"100m"}}
memory: {{"100Mi"}}
env:
- name: {{"GET_HOSTS_FROM"}}
value: {{"dns"}}

@ -1,18 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: {{ "redis-slave" }}
labels:
app: {{ "redis" }}
role: {{ "slave" }}
tier: {{ "backend" }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
ports:
- port: {{.Values.service.redis_slave.port}}
selector:
app: {{.Values.service.redis_slave.selector.app}}
role: {{.Values.service.redis_slave.selector.role}}
tier: {{.Values.service.redis_slave.selector.tier}}

@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "guestbook.fullname" . }}
labels:
app: {{ template "guestbook.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.frontend.type }}
ports:
- port: {{ .Values.service.frontend.externalPort }}
targetPort: {{ .Values.service.frontend.internalPort }}
protocol: TCP
name: {{ .Values.service.name }}
selector:
app: {{ template "guestbook.name" . }}
release: {{ .Release.Name }}

@ -1,43 +1,24 @@
# Default values for mychart.
# Default values for guestbook.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
frontend_deployment:
repository: gcr.io/google-samples/gb-frontend
tag: v4
redis_master:
repository: gcr.io/google_containers/redis
tag: e2e
redis_slave:
repository: gcr.io/google_samples/gb-redisslave
tag: v1
repository: gcr.io/google-samples/gb-frontend
tag: v4
pullPolicy: IfNotPresent
service:
frontend:
type: LoadBalancer
port: 80
externalPort: 80
internalPort: 80
selector:
app: guestbook
tier: frontend
redis_master:
port: 6379
targetPort: 6379
selector:
app: redis
role: master
tier: backend
redis_slave:
port: 6379
selector:
app: redis
role: slave
tier: backend
ingress:
enabled: false
# Used to create an Ingress record.
hosts:
- chart-example.local
#hosts:
# - chart-example.local
annotations:
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
@ -46,14 +27,18 @@ ingress:
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
resources:
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
redis:
enabled: true
externalDatabase:
host: localhost

Loading…
Cancel
Save