Skip to content

Commit

Permalink
Merge v2-master into master (#4044)
Browse files Browse the repository at this point in the history
* Follow redirect - needed for repo move

* Update metric used for cells (#4009)

- `firehose_value_metric_rep_unhealthy_cell` deprecated, now use `firehose_value_metric_rep_garden_health_check_failed`
- Try new metric first and fall back on old

* Fix incorrect SSO behaviour following 2.4.0 --> 2.6.0 upgrade (#4015)

- affects db migration of console config table to new config table
- fixes #4013

* 2.6.1 Release preparation

* Ingress fix (#4024)

* Fixes ingress and kube 1.16 version issue

* Update Changelog

* More test

* Fix ingress tests

* Mention STRATOS_BP_DEBUG to troubleshoot staging (#4039)

* Fix following merge
  • Loading branch information
richard-cox authored and nwmac committed Dec 4, 2019
1 parent b6cf15f commit 9c44228
Show file tree
Hide file tree
Showing 22 changed files with 307 additions and 89 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Change Log

## 2.6.1

[Full Changelog](https://github.com/cloudfoundry/stratos/compare/2.6.0...2.6.1)

This release contains a few fixes:

**Fixes:**

- Helm Chart does not work with Kubernetes 1.16 [\#4022](https://github.com/cloudfoundry/stratos/issues/4022)
- Generated Ingress certificates during Kubernetes deployment are empty [\#4006](https://github.com/cloudfoundry/stratos/issues/4006)
- Kubernetes Ingress certificate is incorrectly set [\#4005](https://github.com/cloudfoundry/stratos/issues/4005)
- Update metric used for cells [\#4009](https://github.com/cloudfoundry/stratos/pull/4009)
- Fix incorrect SSO behaviour following 2.4.0 --> 2.6.0 upgrade [\#4015](https://github.com/cloudfoundry/stratos/pull/4015)

## 2.6.0

[Full Changelog](https://github.com/cloudfoundry/stratos/compare/2.5.0...2.6.0)
Expand Down
2 changes: 1 addition & 1 deletion deploy/ci/tasks/dev-releases/github-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ downloadReleaseFile() {
local parser=". | map(select(.tag_name == \"$VERSION\"))[0].assets | map(select(.name == \"$FILE\"))[0].id"

# Get release information from GitHub
curl -H "Authorization: token $TOKEN" -H "Accept: application/vnd.github.v3.raw" -s $GITHUB/repos/$REPO/releases > releases.json
curl -L -H "Authorization: token $TOKEN" -H "Accept: application/vnd.github.v3.raw" -s $GITHUB/repos/$REPO/releases > releases.json
if [ $? -ne 0 ]; then
echo "Could not download release information for ${REPO}"
exit 1
Expand Down
32 changes: 19 additions & 13 deletions deploy/kubernetes/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ ADD_OFFICIAL_TAG="false"
TAG_LATEST="false"
NO_PUSH="true"
DOCKER_REG_DEFAULTS="true"
CHART_ONLY="false"

while getopts ":ho:r:t:Tclb:On" opt; do
while getopts ":ho:r:t:Tclb:Op" opt; do
case $opt in
h)
echo
Expand Down Expand Up @@ -64,6 +65,9 @@ while getopts ":ho:r:t:Tclb:On" opt; do
p)
NO_PUSH="false"
;;
c)
CHART_ONLY="true"
;;
\?)
echo "Invalid option: -${OPTARG}" >&2
exit 1
Expand Down Expand Up @@ -175,22 +179,24 @@ cleanup

updateTagForRelease

# Build all of the components that make up the Console
if [ "${CHART_ONLY}" == "false" ]; then
# Build all of the components that make up the Console

log "-- Build & publish the runtime container image for Jetstream (backend)"
patchAndPushImage stratos-jetstream deploy/Dockerfile.bk "${STRATOS_PATH}" prod-build
log "-- Build & publish the runtime container image for Jetstream (backend)"
patchAndPushImage stratos-jetstream deploy/Dockerfile.bk "${STRATOS_PATH}" prod-build

# Build the postflight container
log "-- Build & publish the runtime container image for the postflight job"
patchAndPushImage stratos-postflight-job deploy/Dockerfile.bk "${STRATOS_PATH}" postflight-job
# Build the postflight container
log "-- Build & publish the runtime container image for the postflight job"
patchAndPushImage stratos-postflight-job deploy/Dockerfile.bk "${STRATOS_PATH}" postflight-job

# Build and push an image based on the mariab db container
log "-- Building/publishing MariaDB"
patchAndPushImage stratos-mariadb Dockerfile.mariadb "${STRATOS_PATH}/deploy/db"
# Build and push an image based on the mariab db container
log "-- Building/publishing MariaDB"
patchAndPushImage stratos-mariadb Dockerfile.mariadb "${STRATOS_PATH}/deploy/db"

# Build and push an image based on the nginx container (Front-end)
log "-- Building/publishing the runtime container image for the Console web server (frontend)"
patchAndPushImage stratos-console deploy/Dockerfile.ui "${STRATOS_PATH}" prod-build
# Build and push an image based on the nginx container (Front-end)
log "-- Building/publishing the runtime container image for the Console web server (frontend)"
patchAndPushImage stratos-console deploy/Dockerfile.ui "${STRATOS_PATH}" prod-build
fi

log "-- Building Helm Chart"

Expand Down
18 changes: 18 additions & 0 deletions deploy/kubernetes/console/templates/__helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,24 @@ tls.crt: {{ $cert.Cert | b64enc }}
tls.key: {{ $cert.Key | b64enc }}
{{- end -}}

{{/*
Generate self-signed certificate for ingress if needed
*/}}
{{- define "console.generateIngressCertificate" -}}
{{- $altNames := list (printf "%s" .Values.console.service.ingress.host) (printf "%s.%s" (include "console.certName" .) .Release.Namespace ) ( printf "%s.%s.svc" (include "console.certName" .) .Release.Namespace ) -}}
{{- $ca := genCA "stratos-ca" 365 -}}
{{- $cert := genSignedCert ( include "console.certName" . ) nil $altNames 365 $ca -}}
{{- if .Values.console.service.ingress.tls.crt }}
tls.crt: {{ .Values.console.service.ingress.tls.crt | b64enc | quote }}
{{- else }}
tls.crt: {{ $cert.Cert | b64enc | quote }}
{{- end -}}
{{- if .Values.console.service.ingress.tls.key }}
tls.key: {{ .Values.console.service.ingress.tls.key | b64enc | quote }}
{{- else }}
tls.key: {{ $cert.Key | b64enc | quote }}
{{- end -}}
{{- end -}}

{{/*
Ingress Host from .Values.console.service
Expand Down
8 changes: 8 additions & 0 deletions deploy/kubernetes/console/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
{{- if semverCompare ">=1.16" (printf "%s.%s" .Capabilities.KubeVersion.Major .Capabilities.KubeVersion.Minor)}}
apiVersion: apps/v1
{{- else }}
apiVersion: apps/v1beta1
{{- end }}
kind: StatefulSet
metadata:
name: stratos
Expand Down Expand Up @@ -309,7 +313,11 @@ spec:
name: {{ .Values.console.templatesConfigMapName }}
{{- end }}
---
{{- if semverCompare ">=1.16" (printf "%s.%s" .Capabilities.KubeVersion.Major .Capabilities.KubeVersion.Minor)}}
apiVersion: apps/v1
{{- else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Deployment
metadata:
name: stratos-db
Expand Down
12 changes: 9 additions & 3 deletions deploy/kubernetes/console/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,26 @@ metadata:
app.kubernetes.io/component: "console-ingress-tls"
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
data:
tls.crt: {{ .Values.console.service.ingress.tls.crt | default "" | b64enc | quote }}
tls.key: {{ .Values.console.service.ingress.tls.key | default "" | b64enc | quote }}
{{ template "console.generateIngressCertificate" . }}
{{- end }}

---
# Ingress for the Console UI service
{{- if semverCompare ">=1.16" (printf "%s.%s" .Capabilities.KubeVersion.Major .Capabilities.KubeVersion.Minor) }}
apiVersion: "networking.k8s.io/v1beta1"
{{- else }}
apiVersion: "extensions/v1beta1"
{{- end }}
kind: "Ingress"
metadata:
name: "{{ .Release.Name }}-ingress"
annotations:
{{- if hasKey .Values.console.service.ingress.annotations "kubernetes.io/ingress.class" | not -}}
{{ $_ := set .Values.console.service.ingress.annotations "kubernetes.io/ingress.class" "nginx" }}
{{- end }}
{{- if hasKey .Values.console.service.ingress.annotations "kubernetes.io/ingress.allow-http" | not -}}
{{ $_ := set .Values.console.service.ingress.annotations "kubernetes.io/ingress.allow-http" "false" }}
{{- end }}
{{- if hasKey .Values.console.service.ingress.annotations "nginx.ingress.kubernetes.io/secure-backends" | not -}}
{{ $_ := set .Values.console.service.ingress.annotations "nginx.ingress.kubernetes.io/secure-backends" "true" }}
{{- end }}
Expand All @@ -60,7 +66,7 @@ metadata:
{{- end }}
spec:
tls:
- secretName: {{ default "{{ .Release.Name }}-ingress-tls" .Values.console.service.ingress.secretName | quote }}
- secretName: {{ default (print .Release.Name "-ingress-tls") .Values.console.service.ingress.secretName | quote }}
hosts:
- {{ template "ingress.host" . }}
rules:
Expand Down
8 changes: 5 additions & 3 deletions deploy/kubernetes/console/tests/ingress_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ tests:
- equal:
path: kind
value: "Secret"
- equal:
- isNotEmpty:
path: data.tls\.crt
value: ""
- equal:
- isNotEmpty:
path: data.tls\.key
value: ""
- it: should create secret with specified values
Expand Down Expand Up @@ -147,6 +146,7 @@ tests:
- equal:
path: metadata.annotations
value:
kubernetes.io/ingress.allow-http: "false"
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/secure-backends: "true"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
Expand All @@ -171,6 +171,7 @@ tests:
- equal:
path: metadata.annotations
value:
kubernetes.io/ingress.allow-http: "false"
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/secure-backends: "true"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
Expand All @@ -196,6 +197,7 @@ tests:
path: metadata.annotations
value:
test-annotation: "test"
kubernetes.io/ingress.allow-http: "false"
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/secure-backends: "true"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
Expand Down
31 changes: 31 additions & 0 deletions deploy/kubernetes/console/tests/kube_version_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
suite: test stratos deployment with kube versions
templates:
- deployment.yaml
tests:
- it: should use newer API versions when kube >= 1.16
capabilities:
kubeVersion:
major: 1
minor: 16
asserts:
- equal:
path: apiVersion
value: apps/v1
- it: should use newer API versions when kube >= 2
capabilities:
kubeVersion:
major: 2
minor: 1
asserts:
- equal:
path: apiVersion
value: apps/v1
- it: should use older API versions when kube < 1.16
capabilities:
kubeVersion:
major: 1
minor: 14
asserts:
- equal:
path: apiVersion
value: apps/v1beta1
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stratos",
"version": "2.6.0",
"version": "2.6.1",
"description": "Stratos Console",
"main": "index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { combineLatest, Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { map, switchMap } from 'rxjs/operators';

import { EntityServiceFactory } from '../../../../../../../core/src/core/entity-service-factory.service';
import { CfCellHelper } from '../../../../../../../core/src/features/cloud-foundry/cf-cell.helpers';
import { MetricsConfig } from '../../../../../../../core/src/shared/components/metrics-chart/metrics-chart.component';
import { MetricsLineChartConfig } from '../../../../../../../core/src/shared/components/metrics-chart/metrics-chart.types';
import {
MetricsChartHelpers,
} from '../../../../../../../core/src/shared/components/metrics-chart/metrics.component.helpers';
import { PaginationMonitorFactory } from '../../../../../../../core/src/shared/monitors/pagination-monitor.factory';
import { MetricQueryType } from '../../../../../../../core/src/shared/services/metrics-range-selector.types';
import { MetricQueryConfig } from '../../../../../../../store/src/actions/metrics.actions';
import { AppState } from '../../../../../../../store/src/app-state';
import { IMetricMatrixResult, IMetrics, IMetricVectorResult } from '../../../../../../../store/src/types/base-metric.types';
import { IMetricCell } from '../../../../../../../store/src/types/metric.types';
import { FetchCFCellMetricsAction } from '../../../../../actions/cf-metrics.actions';
import { ActiveRouteCfCell } from '../../../cf-page.types';


export const enum CellMetrics {
HEALTHY = 'firehose_value_metric_rep_unhealthy_cell',
/**
* Deprecated since Diego v2.31.0. See https://github.com/bosh-prometheus/prometheus-boshrelease/issues/333
*/
HEALTHY_DEP = 'firehose_value_metric_rep_unhealthy_cell',
/**
* Available from Diego v2.31.0. See https://github.com/bosh-prometheus/prometheus-boshrelease/issues/333
*/
HEALTHY = 'firehose_value_metric_rep_garden_health_check_failed',
REMAINING_CONTAINERS = 'firehose_value_metric_rep_capacity_remaining_containers',
REMAINING_DISK = 'firehose_value_metric_rep_capacity_remaining_disk',
REMAINING_MEMORY = 'firehose_value_metric_rep_capacity_remaining_memory',
Expand All @@ -27,6 +38,10 @@ export const enum CellMetrics {
CPUS = 'firehose_value_metric_rep_num_cpus'
}


/**
* Designed to be used once drilled down to a cell (see ActiveRouteCfCell)
*/
@Injectable()
export class CloudFoundryCellService {

Expand All @@ -52,12 +67,13 @@ export class CloudFoundryCellService {

constructor(
activeRouteCfCell: ActiveRouteCfCell,
private entityServiceFactory: EntityServiceFactory) {
private entityServiceFactory: EntityServiceFactory,
store: Store<AppState>,
paginationMonitorFactory: PaginationMonitorFactory) {

this.cellId = activeRouteCfCell.cellId;
this.cfGuid = activeRouteCfCell.cfGuid;

this.healthy$ = this.generate(CellMetrics.HEALTHY);
this.remainingContainers$ = this.generate(CellMetrics.REMAINING_CONTAINERS);
this.totalContainers$ = this.generate(CellMetrics.TOTAL_CONTAINERS);
this.remainingDisk$ = this.generate(CellMetrics.REMAINING_DISK);
Expand All @@ -70,8 +86,19 @@ export class CloudFoundryCellService {
this.usageDisk$ = this.generateUsage(this.remainingDisk$, this.totalDisk$);
this.usageMemory$ = this.generateUsage(this.remainingMemory$, this.totalMemory$);

this.cellMetric$ = this.generate(CellMetrics.HEALTHY, true);

const cellHelper = new CfCellHelper(store, paginationMonitorFactory);
const action$ = cellHelper.createCellMetricAction(this.cfGuid);
this.cellMetric$ = action$.pipe(
switchMap(action => {
this.healthyMetricId = action.guid;
return this.generate(action.query.metric as CellMetrics, true);
})
);
this.healthy$ = action$.pipe(
switchMap(action => {
return this.generate(action.query.metric as CellMetrics, false);
})
);
}

public buildMetricConfig(
Expand Down Expand Up @@ -99,17 +126,14 @@ export class CloudFoundryCellService {
return lineChartConfig;
}

private generate(metric: CellMetrics, isMetric = false): Observable<any> {
const action = new FetchCFCellMetricsAction(
private generate(metric: CellMetrics, isMetric = false, customAction?: FetchCFCellMetricsAction): Observable<any> {
const action = customAction || new FetchCFCellMetricsAction(
this.cfGuid,
this.cellId,
new MetricQueryConfig(metric + `{bosh_job_id="${this.cellId}"}`, {}),
MetricQueryType.QUERY,
false
);
if (metric === CellMetrics.HEALTHY) {
this.healthyMetricId = action.guid;
}
return this.entityServiceFactory.create<IMetrics<IMetricVectorResult<IMetricCell>>>(
action.guid,
action,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Component } from '@angular/core';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';

import { CfCellHelper } from '../../../../../../core/src/features/cloud-foundry/cf-cell.helpers';
import { ListConfig } from '../../../../../../core/src/shared/components/list/list.component.types';
import { PaginationMonitorFactory } from '../../../../../../core/src/shared/monitors/pagination-monitor.factory';
import { AppState } from '../../../../../../store/src/app-state';
import {
CfCellsListConfigService,
} from '../../../../shared/components/list/list-types/cf-cells/cf-cells-list-config.service';
Expand All @@ -23,7 +27,12 @@ import { CloudFoundryEndpointService } from '../../services/cloud-foundry-endpoi
export class CloudFoundryCellsComponent {
hasCellMetrics$: Observable<boolean>;

constructor(cfEndpointService: CloudFoundryEndpointService) {
this.hasCellMetrics$ = cfEndpointService.hasCellMetrics(cfEndpointService.cfGuid);
constructor(
cfEndpointService: CloudFoundryEndpointService,
store: Store<AppState>,
paginationMonitorFactory: PaginationMonitorFactory
) {
const cellHelper = new CfCellHelper(store, paginationMonitorFactory);
this.hasCellMetrics$ = cellHelper.hasCellMetrics(cfEndpointService.cfGuid);
}
}
Loading

0 comments on commit 9c44228

Please sign in to comment.