Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge branch 'k8s-more-resources-2' of github.com:cloudfoundry/strato…
Browse files Browse the repository at this point in the history
…s into k8s-more-resources-2
  • Loading branch information
nwmac committed Dec 8, 2020
2 parents 41eed4b + a913e8a commit a461d10
Show file tree
Hide file tree
Showing 21 changed files with 177 additions and 142 deletions.
34 changes: 30 additions & 4 deletions deploy/kubernetes/console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ The following table lists the configurable parameters of the Stratos Helm chart
|console.service.servicePort|Service port for the console service|443|
|console.service.externalName|External name for the console service when service type is ExternalName||
|console.service.nodePort|Node port to use for the console service when service type is NodePort or LoadBalancer||
|console.ingress.enabled|Enable ingress for the console service|false|
|console.ingress.host|Host for the ingress resource|||
|console.ingress.secretName|Name of an existing secret containing the TLS certificate for ingress|||
|console.service.ingress.enabled|Enable ingress for the console service|false|
|console.service.ingress.host|Host for the ingress resource|||
|console.service.ingress.secretName|Name of an existing secret containing the TLS certificate for ingress|||
|console.service.http.enabled|Enabled HTTP access to the console service (as well as HTTPS)|false|
|console.service.http.servicePort|Service port for HTTP access to the console service when enabled|80|
|console.service.http.nodePort|Node port for HTTP access to the console service (as well as HTTPS)||
Expand Down Expand Up @@ -192,6 +192,32 @@ helm install my-console stratos/console --namespace=console --set console.servic

## Using an Ingress Controller

### Bare minimum Stratos deployment with an Ingress

1. Deploy `ingress-nginx` Ingress controller into your Kubernetes cluster using the [Helm chart](https://artifacthub.io/packages/helm/ingress-nginx/ingress-nginx) or [Kubernetes spec files](https://kubernetes.github.io/ingress-nginx/deploy/).
2. Create `values.yaml` with the following Stratos Helm chart configuration values:
```
console:
service:
ingress:
enabled: true
```
3. Install Stratos:
```
helm repo add stratos https://cloudfoundry.github.io/stratos
kubectl create namespace console
helm install my-console stratos/console --namespace=console --values values.yaml
```
4. Obtain Ingress address by running `kubectl get ingress --namespace=console`, your Stratos installation should be accessible at that address.

Note that configuration above would result in a deployment with self-signed HTTPS certificates and Stratos service being a default backend for the Ingress. The following steps most likely would be required for a production deployment:

1. Acquire a static IP address for the Ingress.
2. Assign a domain name to the static IP via a DNS record and set `console.service.ingress.host` value.
3. Create a Kubernetes secret containing valid HTTPS certificates for the domain and set `console.service.ingress.secretName` value.

### Ingress configuration

If your Kubernetes Cluster supports Ingress, you can expose Stratos through Ingress by supplying the appropriate ingress configuration when installing.

This configuration is described below:
Expand All @@ -204,7 +230,7 @@ This configuration is described below:
|console.service.ingress.host|The host name that will be used for the Stratos service.||
|console.service.ingress.secretName|The existing TLS secret that contains the certificate for ingress.||

You must provide `console.service.ingress.host` when enabling ingress.
If `console.service.ingress.host` isn't provided, Stratos service will be used as the default backend.

By default a certificate will be generated for TLS. You can provide your own certificate by creating a secret and specifying this with `console.service.ingress.secretName`.

Expand Down
13 changes: 11 additions & 2 deletions deploy/kubernetes/console/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ Tech Preview is enabled, extra features will be shown.
{{- end}}

To access Stratos:
{{- $ingress := .Values.console.ingress | default dict }}
{{- $ingress := .Values.console.service.ingress | default dict }}
{{- if $ingress.enabled }}
From outside the cluster, the server URL is: http://{{ .Values.console.ingress.host }}
{{- if .Values.console.service.ingress.host }}
From outside the cluster, the server URL is: https://{{ .Values.console.service.ingress.host }}
{{- else }}
NOTE: It may take a few minutes for the Ingress IP to become available.
You can watch the status of by running 'kubectl get ingress --namespace {{ .Release.Namespace }} -w {{ .Release.Name }}-ingress'

Get the URL by running these commands in the same shell:
export INGRESS_ADDR=$(kubectl get ingress --namespace {{ .Release.Namespace }} --field-selector 'metadata.name={{ .Release.Name }}-ingress' -o jsonpath='{.items[0].status.loadBalancer.ingress[0].hostname}')
echo https://$INGRESS_ADDR
{{- end }}
{{- else }}
Get the URL by running these commands in the same shell:
{{- if contains "NodePort" .Values.console.service.type }}
Expand Down
2 changes: 0 additions & 2 deletions deploy/kubernetes/console/templates/__helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ Ingress Host:
{{ $host | quote }}
{{- else if .Values.env.DOMAIN -}}
{{ print "console." .Values.env.DOMAIN }}
{{- else -}}
{{ required "Host name is required" $host | quote }}
{{- end -}}
{{- end -}}

Expand Down
11 changes: 8 additions & 3 deletions deploy/kubernetes/console/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ metadata:
{{- if hasKey .Values.console.service.ingress.annotations "nginx.ingress.kubernetes.io/proxy-body-size" | not -}}
{{ $_ := set .Values.console.service.ingress.annotations "nginx.ingress.kubernetes.io/proxy-body-size" "200m" }}
{{- end }}
{{ $_ := set .Values.console.service.ingress.annotations "nginx.org/websocket-services" (print .Release.Name "-ui-ext") }}
{{- $_ := set .Values.console.service.ingress.annotations "nginx.org/websocket-services" (print .Release.Name "-ui-ext") }}
{{ toYaml .Values.console.service.ingress.annotations | indent 4 }}
labels:
app.kubernetes.io/name: "stratos"
Expand All @@ -65,12 +65,17 @@ metadata:
{{ $key }}: {{ $value }}
{{- end }}
spec:
{{- $host := (include "ingress.host" .) }}
tls:
- secretName: {{ default (print .Release.Name "-ingress-tls") .Values.console.service.ingress.secretName | quote }}
{{- if $host }}
hosts:
- {{ template "ingress.host" . }}
- {{ $host }}
{{- end }}
rules:
- host: {{ template "ingress.host" . }}
- {{ if $host -}}
host: {{ $host }}
{{ end -}}
http:
paths:
- path: "/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ export class ListActionOrConfigHelpers {
dsOverrides?: Partial<IListDataSourceConfig<A, T>>
): IListDataSourceConfig<A, T> {
const { action, catalogEntity } = ListActionOrConfigHelpers.createListAction(actionOrConfig);
const schema = catalogEntity.getSchema(action.schemaKey);
return {
store,
action,
paginationKey: action.paginationKey,
schema: catalogEntity.getSchema(action.schemaKey),
getRowUniqueId: entity => catalogEntity.getGuidFromEntity(entity),
getRowUniqueId: entity => {
return catalogEntity.getGuidFromEntity(entity) || schema.getId(entity);
},
listConfig,
isLocal: true, // assume true unless overwritten
...dsOverrides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
font-size: 18px;
height: 25px;
line-height: 25px;
opacity: 60%;
opacity: .6;
padding-left: 5px;
width: 35px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="app-no-content-container__link-text">{{toolbarLink.text}}</div>
<mat-icon #toolbarRef class="app-no-content-container__link-icon">reply</mat-icon>
</div>
<mat-icon [fontSet]="iconFont">{{icon}}</mat-icon>
<mat-icon class="icon" [fontSet]="iconFont">{{icon}}</mat-icon>
<div *ngIf="firstLine" class="first-line">{{firstLine}}</div>
<div class="second-line">
<a *ngIf="secondLine?.link" [routerLink]="secondLine?.link">{{secondLine?.linkText}}</a>{{secondLine?.text}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}
&__link {
display: flex;
opacity: 0%;
opacity: 0;
position: absolute;
right: 113px;
top: 54px;
Expand All @@ -41,7 +41,7 @@
margin-top: 26px;
}
&--show {
opacity: 100%;
opacity: 1;
transition: opacity .6s;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@

.app-no-content-container {
color: $subdued;
&__link,
.icon,
.first-line {
color: mat-color($primary);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
<app-panel *ngIf="!chart && !initing" class="app-panel--container">
<h2>Sorry, we couldn't find the chart</h2>
</app-panel>
<app-panel *ngIf="chart && !currentVersion && !initing" class="app-panel--container">
<h2>Sorry, we couldn't find the version information for this chart</h2>
</app-panel>
<app-loader [loading]="loading">
<div class="chart-details__wrapper">
<app-entity-summary-title class="summary-title" *ngIf="chart" [title]="chart.attributes.name"
[subTitle]="chartSubTitle" [subText]="chart.attributes.description" [imagePath]="iconUrl">
<div class="chart-details__wrapper" *ngIf="chart && currentVersion">
<app-entity-summary-title class="summary-title" [title]="chart.attributes.name" [subTitle]="chartSubTitle"
[subText]="chart.attributes.description" [imagePath]="iconUrl">
<div class="chart-details__content">
<article class="chart-details__content__docs">
<app-chart-details-readme [currentVersion]=currentVersion></app-chart-details-readme>
<app-chart-details-readme [currentVersion]="currentVersion"></app-chart-details-readme>
</article>
</div>
</app-entity-summary-title>
<aside *ngIf="chart" class="chart-details__content__info">
<app-chart-details-info [chart]=chart [currentVersion]=currentVersion></app-chart-details-info>
<aside class="chart-details__content__info">
<app-chart-details-info [chart]="chart" [currentVersion]="currentVersion"></app-chart-details-info>
</aside>
</div>
</app-loader>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { first } from 'rxjs/operators';
import { finalize, first, switchMap, tap } from 'rxjs/operators';

import { Chart } from '../shared/models/chart';
import { ChartVersion } from '../shared/models/chart-version';
Expand Down Expand Up @@ -39,24 +39,30 @@ export class ChartDetailsComponent implements OnInit {
const chartName = params.chartName;

if (!!chartName) {
this.chartsService.getChart(repo, chartName).pipe(first()).subscribe(chart => {
clearTimeout(this.loadingDelay);
this.loading = false;
this.initing = false;
this.chart = chart;
this.chartSubTitle = chart.attributes.repo.name;
if (getMonocularEndpoint(this.route, chart) !== stratosMonocularEndpointGuid) {
this.chartSubTitle = 'Artifact Hub - ' + this.chartSubTitle;
}
const version = params.version || this.chart.relationships.latestChartVersion.data.version;
this.chartsService.getVersion(repo, chartName, version).pipe(first())
.subscribe(chartVersion => {
this.currentVersion = chartVersion;
this.titleVersion = this.currentVersion.attributes.app_version || '';
this.updateMetaTags();
this.iconUrl = this.chartsService.getChartIconURL(this.chart, chartVersion);
});
});
this.chartsService.getChart(repo, chartName).pipe(
first(),
switchMap(chart => {
clearTimeout(this.loadingDelay);
this.chart = chart;
this.chartSubTitle = chart.attributes.repo.name;
if (getMonocularEndpoint(this.route, chart) !== stratosMonocularEndpointGuid) {
this.chartSubTitle = 'Artifact Hub - ' + this.chartSubTitle;
}
const version = params.version || this.chart.relationships.latestChartVersion.data.version;
return this.chartsService.getVersion(repo, chartName, version).pipe(first());
}),
tap(chartVersion => {
this.currentVersion = chartVersion;
this.titleVersion = this.currentVersion.attributes.app_version || '';
this.updateMetaTags();
this.iconUrl = this.chartsService.getChartIconURL(this.chart, chartVersion);
}),
finalize(() => {
clearTimeout(this.loadingDelay);
this.loading = false;
this.initing = false;
})
).subscribe();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from '@angular/core';
import { Component, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store';
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs';
import { distinctUntilChanged, filter, first, map, startWith } from 'rxjs/operators';

import { ListConfig } from '../../../../../core/src/shared/components/list/list.component.types';
Expand All @@ -24,7 +24,7 @@ const REPO_FILTER_NAME = 'repository';
}]

})
export class CatalogTabComponent {
export class CatalogTabComponent implements OnDestroy {

public repos$: Observable<{
artifactHubRepos: string[],
Expand All @@ -39,6 +39,9 @@ export class CatalogTabComponent {
public collapsed = true;
public hide = true;

private initStateSet = false;
private sub: Subscription;

constructor(private store: Store<AppState>, private activatedRoute: ActivatedRoute) {
// Determine the starting state of the filter by repo section
stratosEntityCatalog.endpoint.store.getAll.getPaginationService().entities$.pipe(
Expand Down Expand Up @@ -89,15 +92,20 @@ export class CatalogTabComponent {
startWith(null)
);

helmEntityCatalog.chart.store.getPaginationMonitor().pagination$.pipe(
first()
).subscribe(pagination => {
const { repo } = this.activatedRoute.snapshot.params;
if (repo && repo.length > 0) {
this.filterCharts(repo);
} else {
this.filteredRepo = pagination.clientPagination?.filter?.items?.[REPO_FILTER_NAME];
const { repo: repoFromRoute } = this.activatedRoute.snapshot.params;
const repoFromStore$ = helmEntityCatalog.chart.store.getPaginationMonitor().pagination$.pipe(
map(pagination => pagination.clientPagination?.filter?.items?.[REPO_FILTER_NAME])
);

// Set the initial state... and watch for changes (aka reset filters button)
this.sub = repoFromStore$.subscribe(repoFromStore => {
// Only apply repo from url on first load (and if we have one)
if (!this.initStateSet && repoFromRoute && repoFromRoute.length > 0) {
this.filterCharts(repoFromRoute);
} else if (this.filteredRepo !== repoFromStore) {
this.filteredRepo = repoFromStore;
}
this.initStateSet = true;
});
}

Expand All @@ -123,4 +131,10 @@ export class CatalogTabComponent {
public searchRepos(repoName: string) {
this.searchReposSub.next(repoName);
}

ngOnDestroy(): void {
if (this.sub) {
this.sub.unsubscribe();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<app-tile-grid fit="true">
<app-tile-group class="k8s-home-card__plain-tiles">
<app-tile>
<app-card-number-metric mode="plain" link="/kubernetes/{{endpoint.guid}}/nodes"
icon="apps" label="Nodes" labelSingular="Node" value="{{ nodeCount$ | async }}">
<app-card-number-metric mode="plain" link="/kubernetes/{{endpoint.guid}}/nodes" icon="apps" label="Nodes"
labelSingular="Node" value="{{ nodeCount$ | async }}">
</app-card-number-metric>
</app-tile>
<app-tile>
<app-card-number-metric mode="plain" link="/kubernetes/{{endpoint.guid}}/namespaces"
icon="language" label="Namespaces" labelSingular="Node" value="{{ namespaceCount$ | async }}">
<app-card-number-metric mode="plain" link="/kubernetes/{{endpoint.guid}}/resource/namespace" icon="language"
label="Namespaces" labelSingular="Node" value="{{ namespaceCount$ | async }}">
</app-card-number-metric>
</app-tile>
<app-tile>
<app-card-number-metric mode="plain" link="/kubernetes/{{endpoint.guid}}/pods"
icon="apps" label="Pods" labelSingular="Pod" value="{{ podCount$ | async }}">
<app-card-number-metric mode="plain" link="/kubernetes/{{endpoint.guid}}/resource/pod" icon="apps" label="Pods"
labelSingular="Pod" value="{{ podCount$ | async }}">
</app-card-number-metric>
</app-tile>
</app-tile-group>
Expand Down
Loading

0 comments on commit a461d10

Please sign in to comment.