chartutil create ingress example

pull/2188/head
Scott Rigby 8 years ago
parent ea61ace808
commit 37fd7df627

@ -36,6 +36,8 @@ const (
ChartsDir = "charts" ChartsDir = "charts"
// IgnorefileName is the name of the Helm ignore file. // IgnorefileName is the name of the Helm ignore file.
IgnorefileName = ".helmignore" IgnorefileName = ".helmignore"
// IngressFileName is the name of the example ingress file.
IngressFileName = "ingress.yaml"
// DeploymentName is the name of the example deployment file. // DeploymentName is the name of the example deployment file.
DeploymentName = "deployment.yaml" DeploymentName = "deployment.yaml"
// ServiceName is the name of the example service file. // ServiceName is the name of the example service file.
@ -59,6 +61,18 @@ service:
type: ClusterIP type: ClusterIP
externalPort: 80 externalPort: 80
internalPort: 80 internalPort: 80
ingress:
enabled: false
# Used to create Ingress record (should used with service.type: ClusterIP).
# hostname: chart-example.local
annotations:
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
tls:
# Secrets must be manually created in the namespace.
# - secretName: chart-example.local
# hosts:
# - chart-example.local
resources: resources:
limits: limits:
cpu: 100m cpu: 100m
@ -92,6 +106,36 @@ const defaultIgnore = `# Patterns to ignore when building packages.
*.tmproj *.tmproj
` `
const defaultIngress = `{{- if .Values.ingress.enabled -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
annotations:
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
rules:
- host: {{ .Values.ingress.hostname }}
http:
paths:
- path: /
backend:
serviceName: {{ template "fullname" . }}
servicePort: 80
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end -}}
{{- end -}}
`
const defaultDeployment = `apiVersion: extensions/v1beta1 const defaultDeployment = `apiVersion: extensions/v1beta1
kind: Deployment kind: Deployment
metadata: metadata:
@ -141,7 +185,9 @@ spec:
` `
const defaultNotes = `1. Get the application URL by running these commands: const defaultNotes = `1. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.service.type }} {{- if .Values.ingress.hostname }}
http://{{- .Values.ingress.hostname }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }}) export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT/login echo http://$NODE_IP:$NODE_PORT/login
@ -247,6 +293,11 @@ func Create(chartfile *chart.Metadata, dir string) (string, error) {
path: filepath.Join(cdir, IgnorefileName), path: filepath.Join(cdir, IgnorefileName),
content: []byte(defaultIgnore), content: []byte(defaultIgnore),
}, },
{
// ingress.yaml
path: filepath.Join(cdir, TemplatesDir, IngressFileName),
content: []byte(defaultIngress),
},
{ {
// deployment.yaml // deployment.yaml
path: filepath.Join(cdir, TemplatesDir, DeploymentName), path: filepath.Join(cdir, TemplatesDir, DeploymentName),

Loading…
Cancel
Save