diff --git a/docs/examples/README.md b/docs/examples/README.md index aa42ee07586f96e10a3e4d18129d544bc5fcbb3c..723040ca84bfbc12349906e9cb6fb552998f5c68 100644 --- a/docs/examples/README.md +++ b/docs/examples/README.md @@ -2,3 +2,18 @@ This directory contains example charts to help you get started with chart development. + +## Alpine + +The `alpine` chart is very simple, and is a good starting point. + +It simply deploys a single pod running Alpine Linux. + +## Nginx + +The `nginx` chart shows how to compose several resources into one chart, +and it illustrates more complex template usage. + +It deploys a `deployment` (which creates a `replica set`), a `config +map`, and a `service`. The replica set starts an nginx pod. The config +map stores the files that the nginx server can serve. diff --git a/docs/examples/nginx/.helmignore b/docs/examples/nginx/.helmignore new file mode 100644 index 0000000000000000000000000000000000000000..435b756d88557faadb806d8df4130c39f1aa184d --- /dev/null +++ b/docs/examples/nginx/.helmignore @@ -0,0 +1,5 @@ +# 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 +.git diff --git a/docs/examples/nginx/Chart.yaml b/docs/examples/nginx/Chart.yaml new file mode 100755 index 0000000000000000000000000000000000000000..3f8b733240aa84014ea8753799a3dc7858d0f245 --- /dev/null +++ b/docs/examples/nginx/Chart.yaml @@ -0,0 +1,14 @@ +name: nginx +description: A basic NGINX HTTP server +version: 0.1.0 +keywords: + - http + - nginx + - www + - web +home: "https://github.com/kubernetes/helm" +sources: + - "https://hub.docker.com/_/nginx/" +maintainers: + - name: technosophos + email: mbutcher@deis.com diff --git a/docs/examples/nginx/README.md b/docs/examples/nginx/README.md new file mode 100644 index 0000000000000000000000000000000000000000..379ecd64378bf66abcd0c71a431c7786e9994ecb --- /dev/null +++ b/docs/examples/nginx/README.md @@ -0,0 +1,29 @@ +# nginx: An advanced example chart + +This Helm chart provides examples of some of Helm's more powerful +features. + +**This is not a production-grade chart. It is an example.** + +The chart installs a simple nginx server according to the following +pattern: + +- A `ConfigMap` is used to store the files the server will serve. + (`templates/configmap.yaml`) +- A `Deployment` is used to create a Replica Set of nginx pods. + (`templates/deployment.yaml`) +- A `Service` is used to create a gateway to the pods running in the + replica set (`templates/svc.yaml`) + +The `values.yaml` exposes a few of the configuration options in the +charts, though there are some that are not exposed there (like +`.image`). + +The `templates/_helpers.tpl` file contains helper templates. The leading +underscore (`_`) on the filename is semantic. It tells the template renderer +that this file does not contain a manifest. That file declares some +templates that are used elsewhere in the chart. + +You can deploy this chart with `helm install docs/examples/nginx`. Or +you can see how this chart would render with `helm install --dry-run +--debug docs/examples/nginx`. diff --git a/docs/examples/nginx/templates/_helpers.tpl b/docs/examples/nginx/templates/_helpers.tpl new file mode 100644 index 0000000000000000000000000000000000000000..1727e9b09165980d9f0b153ccf2c6e11bedd64db --- /dev/null +++ b/docs/examples/nginx/templates/_helpers.tpl @@ -0,0 +1,13 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{define "name"}}{{default "nginx" .nameOverride | trunc 24 }}{{end}} + +{{/* +Create a default fully qualified app name. + +We truncate at 24 chars because some Kubernetes name fields are limited to this +(by the DNS naming spec). +*/}} +{{define "fullname"}}{{.Release.Name}}-{{default "nginx" .nameOverride | trunc 24 }}{{end}} diff --git a/docs/examples/nginx/templates/configmap.yaml b/docs/examples/nginx/templates/configmap.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f8b57793b825b4294e1eb9f2cc3e51473027fae3 --- /dev/null +++ b/docs/examples/nginx/templates/configmap.yaml @@ -0,0 +1,14 @@ +# This is a simple example of using a config map to create a single page +# static site. +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{template "fullname" .}} + labels: + release: {{.Release.Name}} + app: {{template "fullname" .}} +data: + # When the config map is mounted as a volume, these will be created as + # files. + index.html: {{default "Hello" .index | squote}} + test.txt: test diff --git a/docs/examples/nginx/templates/deployment.yaml b/docs/examples/nginx/templates/deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f70069c186141f1d74f5a1348794d6ab05cbd5db --- /dev/null +++ b/docs/examples/nginx/templates/deployment.yaml @@ -0,0 +1,39 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + # This uses a "fullname" template (see _helpers) + # Basing names on .Release.Name means that the same chart can be installed + # multiple times into the same namespace. + name: {{template "fullname" .}} + labels: + heritage: helm + # This makes it easy to search using kubectl + release: {{.Release.Name}} + # This makes it easy to audit chart usage. + chart: {{.Chart.Name}}-{{.Chart.Version}} +spec: + replicas: {{default 1 .replicaCount}} + template: + metadata: + labels: + app: {{template "fullname" .}} + release: {{.Release.Name}} + spec: + containers: + - name: {{template "fullname" .}} + # Making image configurable is not necessary. Making imageTag configurable + # is a nice option for the user. Especially in the strange cases like + # nginx where the base distro is determined by the tag. Using :latest + # is frowned upon, using :stable isn't that great either. + image: "{{default "nginx" .image}}:{{default "stable-alpine" .imageTag}}" + imagePullPolicy: {{default "IfNotPresent" .pullPolicy}} + ports: + - containerPort: 80 + # This (and the volumes section below) mount the config map as a volume. + volumeMounts: + - mountPath: /usr/share/nginx/html + name: wwwdata-volume + volumes: + - name: wwwdata-volume + configMap: + name: {{template "fullname" .}} diff --git a/docs/examples/nginx/templates/svc.yaml b/docs/examples/nginx/templates/svc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e52e4f5a0537d9c0d4ded1372e703a1604056a3d --- /dev/null +++ b/docs/examples/nginx/templates/svc.yaml @@ -0,0 +1,17 @@ +# This is a service gateway to the replica set created by the deployment. +apiVersion: v1 +kind: Service +metadata: + name: {{template "fullname" .}} + labels: + heritage: helm + release: {{.Release.Name}} + chart: {{.Chart.Name}}-{{.Chart.Version}} +spec: + ports: + - port: {{default 80 .httpPort}} + targetPort: 80 + protocol: TCP + name: http + selector: + app: {{template "fullname" .}} diff --git a/docs/examples/nginx/values.yaml b/docs/examples/nginx/values.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b32a829655d67804234191d4a67ab2db4e94a2b7 --- /dev/null +++ b/docs/examples/nginx/values.yaml @@ -0,0 +1,16 @@ +# Default values for nginx. +# This is a YAML-formatted file. +# Declare name/value pairs to be passed into your templates. + +# See the list at https://hub.docker.com/r/library/nginx/tags/ +imageTag: "1.11.0" + +# The port (defined on the service) to access the HTTP server. +httpPort: 8888 + +# Number of nginx instances to run +replicaCount: 1 + +index: >- + <h1>Hello</h1> + <p>This is a test</p>