Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm port configuration improvements and unit tests #3264

Merged
merged 9 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ jobs:
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
script:
- npm run test-backend
- name: Helm Chart Unit Tests
script:
- "./deploy/ci/travis/helm-chart-unit-tests.sh"
- name: E2E Tests - Long Suite
before_script:
- "./deploy/ci/travis/job-e2e-before_script.sh"
Expand Down
26 changes: 26 additions & 0 deletions deploy/ci/travis/helm-chart-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e

echo "Stratos Helm Chart Unit Tests"
echo "============================="

echo "Installing Helm"
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.sh
chmod 700 get_helm.sh
./get_helm.sh

echo "Helm Init (Client)"
helm init --client-only

helm version --client

echo "Install Helm unit test plugin"
helm plugin install https://github.com/cf-stratos/helm-unittest

# Run unit tests
cd deploy/kubernetes
helm unittest console

# Run lint
helm lint console
35 changes: 3 additions & 32 deletions deploy/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,18 @@ To login use the following credentials detailed [here](../../docs/access.md).

## Advanced Topics
### Using a Load Balancer
If your Kubernetes deployment supports automatic configuration of a load balancer (e.g. Google Container Engine), specify the parameters `useLb=true` when installing.
If your Kubernetes deployment supports automatic configuration of a load balancer (e.g. Google Container Engine), specify the parameters `console.service.type=LoadBalancer` when installing.

```
helm install stratos/console --namespace=console --name my-console --set useLb=true
helm install stratos/console --namespace=console --name my-console --set console.service.type=LoadBalancer
```

### Specifying an External IP

If the kubernetes cluster supports external IPs for services (see [ Service External IPs](https://kubernetes.io/docs/concepts/services-networking/service/#external-ips)), then the following arguments can be provided. In this following example the dashboard will be available at `https://192.168.100.100:5000`.

```
helm install stratos/console --namespace=console --name my-console --set console.externalIP=192.168.100.100 console.port=5000
helm install stratos/console --namespace=console --name my-console --set console.service.externalIPs={192.168.100.100} --set console.service.servicePort=5000
```

### Upgrading your deployment
Expand Down Expand Up @@ -351,32 +351,3 @@ Install
```
helm install stratos/console --namespace=console --name my-console --version 2.0.0-dev-9a5611dc
```

### Enabled Metrics

[Stratos Metrics](https://github.com/suse/stratos-metrics) can be deployed as part of the Stratos helm chart. The following override file will configure the Metrics component to fetch metrics from a PCF Dev instance.

Save the following to a file called `values.yaml`
```
consoleVersion: 2.0.0
metrics:
enabled: true
env:
CLUSTER_ADMIN_PASSWORD: admin
UAA_CF_IDENTITY_ZONE: uaa
DOMAIN: local.pcfdev.io
UAA_ADMIN_CLIENT_SECRET: admin-client-secret
UAA_HOST: uaa.local.pcfdev.io
UAA_PORT: 443
DOPPLER_PORT: 443
firehoseExporter:
noIdentityZone: true
```

Deploy Stratos with Metrics enabled
```
$ helm install ./console -f values.yaml --name console --namespace stratos

```

The metrics endpoint will be available as `https://console-metrics-nginx`. This can registered as an endpoint in Stratos as a `Metrics` type.
1 change: 1 addition & 0 deletions deploy/kubernetes/console/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
.project
.idea/
*.tmproj
tests/
37 changes: 34 additions & 3 deletions deploy/kubernetes/console/templates/__helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ Image pull secret
{{- printf "{\"%s\":{\"username\": \"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\": \"%s\"}}" .Values.kube.registry.hostname .Values.kube.registry.username .Values.kube.registry.password .Values.kube.registry.email (printf "%s:%s" .Values.kube.registry.username .Values.kube.registry.password | b64enc) | b64enc }}
{{- end }}


{{/*
Determine external IP:
Determine external IPs:
This will do the following:
1. Check for Legacy SCF Config format
2. Check for Console specific External IP
3. Check for New SCf Config format
3. Check for New SCF Config format
4. Check for new Console External IPS
*/}}
{{- define "service.externalIPs" -}}
{{- if .Values.kube.external_ip -}}
Expand All @@ -22,9 +24,14 @@ This will do the following:
{{- range .Values.kube.external_ips -}}
{{ printf "\n- %s" . | indent 4 -}}
{{- end -}}
{{- else if .Values.console.service.externalIPs -}}
{{- range .Values.console.service.externalIPs -}}
{{ printf "\n- %s" . | indent 4 -}}
{{- end -}}
{{- end -}}
{{- end -}}


{{/*
Get SCf UAA Endpoint
*/}}
Expand All @@ -34,4 +41,28 @@ Get SCf UAA Endpoint
{{- else if .Values.env.UAA_HOST -}}
{{- printf "https://scf.%s:%v" .Values.env.UAA_HOST .Values.env.UAA_PORT -}}
{{- end -}}
{{- end -}}
{{- end -}}


{{/*
Service type:
*/}}
{{- define "service.serviceType" -}}
{{- if or .Values.useLb .Values.services.loadbalanced -}}
LoadBalancer
{{- else -}}
{{- printf "%s" .Values.console.service.type -}}
{{- end -}}
{{- end -}}


{{/*
Service port:
*/}}
{{- define "service.servicePort" -}}
{{- if and .Values.kube.external_ips .Values.kube.external_console_https_port -}}
{{ printf "%v" .Values.kube.external_console_https_port }}
{{- else -}}
{{ .Values.console.service.servicePort }}
{{- end -}}
{{- end -}}
59 changes: 41 additions & 18 deletions deploy/kubernetes/console/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apiVersion: v1
kind: Service
metadata:
{{- if .Values.console.service.annotations }}
annotations:
{{ toYaml .Values.console.service.annotations | indent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: "stratos"
app.kubernetes.io/instance: "{{ .Release.Name }}"
Expand All @@ -9,32 +13,51 @@ metadata:
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
name: "{{ .Release.Name }}-ui-ext"
spec:
selector:
app: "{{ .Release.Name }}"
component: console
{{- if .Values.console.service.clusterIP }}
clusterIP: {{ .Values.console.service.clusterIP }}
{{- end }}
{{- if or .Values.console.service.externalIPs .Values.kube.external_ip .Values.console.externalIP .Values.kube.external_ips }}
externalIPs:
{{ template "service.externalIPs" . }}
{{- end }}
{{- if .Values.console.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.console.service.loadBalancerIP }}
{{- end }}
{{- if .Values.console.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- range $cidr := .Values.console.service.loadBalancerSourceRanges }}
- {{ $cidr }}
{{- end }}
{{- end }}
{{- if .Values.console.service.externalName }}
externalName: {{ .Values.console.service.externalName }}
{{- end }}

# Note: HTTP Port is optional - HTTPS port is always included
# HTTP Service (optional)
ports:
{{- if .Values.kube.console_http_port }}
{{- if .Values.console.service.http.enabled }}
- name: http
port: {{ .Values.kube.console_http_port }}
port: {{ .Values.console.service.http.servicePort }}
protocol: TCP
targetPort: 80
{{- if .Values.console.service.http.nodePort }}
nodePort: {{ .Values.console.service.http.nodePort }}
{{- end }}
{{- end }}
# HTTPS Service
- name: https
{{- if and (or .Values.kube.external_ip .Values.console.externalIP .Values.kube.external_ips) .Values.kube.external_console_https_port }}
port: {{ .Values.kube.external_console_https_port }}
{{- else }}
port: {{ .Values.console.port }}
{{- end }}
port: {{ template "service.servicePort" . }}
protocol: TCP
targetPort: 443
selector:
app: "{{ .Release.Name }}"
component: console
{{- if or .Values.useLb .Values.services.loadbalanced }}
type: LoadBalancer
{{- else }}
type: NodePort
{{- end }}
{{- if or .Values.kube.external_ip .Values.console.externalIP .Values.kube.external_ips }}
externalIPs: {{ template "service.externalIPs" . }}
{{- end }}
{{- if .Values.console.service.nodePort }}
nodePort: {{ .Values.console.service.nodePort }}
{{- end }}
type: {{ template "service.serviceType" . }}

---
apiVersion: v1
kind: Service
Expand Down
Loading