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

feat: support cluster mode deployment with the new kustomize-based installation #94

Merged
merged 3 commits into from
Jan 25, 2022
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
8 changes: 0 additions & 8 deletions deploy/base/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,8 @@ spec:
periodSeconds: 5
timeoutSeconds: 1
env:
- name: HAWTIO_ONLINE_MODE
value: namespace
- name: HAWTIO_ONLINE_AUTH
value: form
- name: HAWTIO_ONLINE_RBAC_ACL
value: /etc/hawtio/rbac/ACL.yaml
- name: HAWTIO_ONLINE_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
resources:
requests:
cpu: "0.2"
Expand Down
2 changes: 0 additions & 2 deletions deploy/base/kustomization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ resources:
- configmap-hawtio-rbac.yml
- deployment.yml
- service.yml
- ingress.yml
- serviceaccount.yml
File renamed without changes.
11 changes: 11 additions & 0 deletions deploy/k8s/cluster/kustomization.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
- ../../base

resources:
- ingress.yml

patchesStrategicMerge:
- patch-deployment.yml
14 changes: 14 additions & 0 deletions deploy/k8s/cluster/patch-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hawtio-online
spec:
template:
spec:
containers:
- name: hawtio-online
env:
- name: HAWTIO_ONLINE_AUTH
value: form
- name: HAWTIO_ONLINE_MODE
value: cluster
23 changes: 23 additions & 0 deletions deploy/k8s/namespace/ingress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hawtio-online
labels:
app: hawtio
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
tls:
- secretName: hawtio-online-tls-serving
rules:
- http:
paths:
- path: /(.*)
pathType: Prefix
backend:
service:
name: hawtio-online
port:
number: 443
12 changes: 12 additions & 0 deletions deploy/k8s/namespace/kustomization.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
- ../../base

resources:
- ingress.yml
- serviceaccount.yml

patchesStrategicMerge:
- patch-deployment.yml
18 changes: 18 additions & 0 deletions deploy/k8s/namespace/patch-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hawtio-online
spec:
template:
spec:
containers:
- name: hawtio-online
env:
- name: HAWTIO_ONLINE_AUTH
value: form
- name: HAWTIO_ONLINE_MODE
value: namespace
- name: HAWTIO_ONLINE_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
File renamed without changes.
12 changes: 12 additions & 0 deletions deploy/openshift/cluster/kustomization.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
- ../../base

resources:
- route.yml

patchesStrategicMerge:
- patch-deployment.yml
- patch-service.yml
21 changes: 21 additions & 0 deletions deploy/openshift/cluster/oauthclient.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# OAuthClient requires a redirect URI with a route host name which
# the platform assigns to the route.

set -eu -o pipefail

redirect_uri=${1:-}
if [ -z "$redirect_uri" ]; then
redirect_uri=$(oc get route hawtio-online -ojsonpath='{$.spec.host}')
fi

cat <<EOT | oc apply -f -
apiVersion: oauth.openshift.io/v1
kind: OAuthClient
metadata:
name: hawtio-online
grantMethod: auto
redirectURIs:
- https://${redirect_uri}
EOT
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@ spec:
env:
- name: HAWTIO_ONLINE_AUTH
value: oauth
- name: HAWTIO_ONLINE_MODE
value: cluster
- name: HAWTIO_ONLINE_GATEWAY
value: 'true'
- name: OPENSHIFT_WEB_CONSOLE_URL
value: ${OPENSHIFT_WEB_CONSOLE_URL}
value: ''
- name: OPENSHIFT_CLUSTER_VERSION
value: '4'
volumeMounts:
- name: hawtio-online-tls-serving
mountPath: /etc/tls/private/serving
- name: hawtio-online-tls-proxying
mountPath: /etc/tls/private/proxying
volumes:
- name: hawtio-online-tls-serving
secret:
secretName: hawtio-online-tls-serving
- name: hawtio-online-tls-proxying
secret:
secretName: hawtio-online-tls-proxying
File renamed without changes.
5 changes: 0 additions & 5 deletions deploy/openshift/delete-ingress.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
- ../base
- ../../base

resources:
- route.yml
- serviceaccount.yml

patchesStrategicMerge:
- deployment.yml
- service.yml
- serviceaccount.yml
- delete-ingress.yml
- patch-deployment.yml
- patch-service.yml
31 changes: 31 additions & 0 deletions deploy/openshift/namespace/patch-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hawtio-online
spec:
template:
spec:
containers:
- name: hawtio-online
env:
- name: HAWTIO_ONLINE_AUTH
value: oauth
- name: HAWTIO_ONLINE_MODE
value: namespace
- name: HAWTIO_ONLINE_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: HAWTIO_ONLINE_GATEWAY
value: 'true'
- name: OPENSHIFT_WEB_CONSOLE_URL
value: ''
- name: OPENSHIFT_CLUSTER_VERSION
value: '4'
volumeMounts:
- name: hawtio-online-tls-proxying
mountPath: /etc/tls/private/proxying
volumes:
- name: hawtio-online-tls-proxying
secret:
secretName: hawtio-online-tls-proxying
6 changes: 6 additions & 0 deletions deploy/openshift/namespace/patch-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Service
metadata:
name: hawtio-online
annotations:
service.beta.openshift.io/serving-cert-secret-name: hawtio-online-tls-serving
13 changes: 13 additions & 0 deletions deploy/openshift/namespace/route.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: hawtio-online
labels:
app: hawtio
spec:
to:
kind: Service
name: hawtio-online
tls:
insecureEdgeTerminationPolicy: Redirect
termination: reencrypt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: hawtio-online
labels:
app: hawtio
annotations:
# All HTTPS ingresses for the Hawtio Online route
serviceaccounts.openshift.io/oauth-redirecturi.route: https://
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@
"test": "yarn test:bats",
"test:bats": "cd docker/osconsole/ && bats config.bats",
"test:nginx": "cd docker/ && HAWTIO_ONLINE_RBAC_ACL= njs test.js",
"deploy:k8s": "kubectl apply --kustomize deploy/base/",
"deploy:openshift": "kubectl apply --kustomize deploy/openshift/",
"deploy:k8s:namespace": "kubectl apply --kustomize deploy/k8s/namespace/",
"deploy:k8s:cluster": "kubectl apply --kustomize deploy/k8s/cluster/",
"deploy:openshift:namespace": "oc apply --kustomize deploy/openshift/namespace/",
"deploy:openshift:cluster": "oc apply --kustomize deploy/openshift/cluster/ && ./deploy/openshift/cluster/oauthclient.sh $ROUTE_HOSTNAME",
"k8s:kustomize": "cd deploy/base && kustomize edit set image hawtio/online=docker.io/${ORG:-hawtio}/${PROJECT:-online}:${TAG:-latest}"
},
"devDependencies": {
Expand Down