Skip to content

Commit

Permalink
Merge pull request #1075 from lamw/issue-1066
Browse files Browse the repository at this point in the history
feat: Integrate Tanzu Sources (vSphere/Horizon) for Knative
  • Loading branch information
lamw authored Jul 10, 2023
2 parents e01957c + b4d6f40 commit 9ba9cdc
Show file tree
Hide file tree
Showing 33 changed files with 432 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
#@ load("@ytt:data", "data")

#@ load("@ytt:json", "json")
#@ vcenter = json.decode(data.values.config)["ESCAPED_VCENTER_SERVER"]
#@ vcenterUsername = json.decode(data.values.config)["ESCAPED_VCENTER_USERNAME"]
#@ vcenterPassword = json.decode(data.values.config)["ESCAPED_VCENTER_PASSWORD"]
#@ vcenterTls = json.decode(data.values.config)["VCENTER_DISABLE_TLS"]

#@ webhookUsername = json.decode(data.values.config)["ESCAPED_WEBHOOK_USERNAME"]
#@ webhookPassword = json.decode(data.values.config)["ESCAPED_WEBHOOK_PASSWORD"]
#@ routerName = "vmware-event-router-config-knative-" + data.values.eventProvider

apiVersion: event-router.vmware.com/v1alpha1
Expand All @@ -23,48 +20,6 @@ eventProcessor:
name: default
namespace: vmware-functions
eventProvider:
#@ if data.values.eventProvider == "vcenter":
name: veba-vc-01
type: vcenter
vcenter:
address: #@ "https://"+vcenter+"/sdk"
auth:
basicAuth:
username: #@ vcenterUsername
password: #@ vcenterPassword
type: basic_auth
#@ if vcenterTls == "True":
insecureSSL: true
#@ else:
insecureSSL: false
#@ end
checkpoint: false
#@ end
#@ if data.values.eventProvider == "horizon":
#@ horizon = json.decode(data.values.config)["ESCAPED_HORIZON_SERVER"]
#@ horizonDomain = json.decode(data.values.config)["HORIZON_DOMAIN"]
#@ horizonUsername = json.decode(data.values.config)["ESCAPED_HORIZON_USERNAME"]
#@ horizonPassword = json.decode(data.values.config)["ESCAPED_HORIZON_PASSWORD"]
#@ horizonNoTLS = json.decode(data.values.config)["HORIZON_DISABLE_TLS"]
name: veba-horizon-01
type: horizon
horizon:
address: #@ "https://"+horizon
auth:
type: active_directory
activeDirectoryAuth:
domain: #@ horizonDomain
username: #@ horizonUsername
password: #@ horizonPassword
#@ if horizonNoTLS == "True":
insecureSSL: true
#@ else:
insecureSSL: false
#@ end
#@ end
#@ if data.values.eventProvider == "webhook":
#@ webhookUsername = json.decode(data.values.config)["ESCAPED_WEBHOOK_USERNAME"]
#@ webhookPassword = json.decode(data.values.config)["ESCAPED_WEBHOOK_PASSWORD"]
name: veba-webhook-01
type: webhook
webhook:
Expand All @@ -77,7 +32,6 @@ eventProvider:
username: #@ webhookUsername
password: #@ webhookPassword
#@ end
#@ end
kind: RouterConfig
metadata:
name: #@ routerName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ spec:
name: metrics
protocol: TCP
targetPort: 8082
#@ if data.values.eventProvider == "webhook":
- port: 8080
name: webhook
protocol: TCP
targetPort: 8080
#@ end
selector:
app: #@ routerName
sessionAffinity: None
Expand Down
27 changes: 27 additions & 0 deletions files/configs/horizon-source/templates/horizon-source-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#@ load("@ytt:overlay", "overlay")
#@ load("@ytt:data", "data")

#@ load("@ytt:json", "json")
#@ horizon = json.decode(data.values.config)["ESCAPED_HORIZON_SERVER"]
#@ horizonDisableTls = json.decode(data.values.config)["HORIZON_DISABLE_TLS"]

apiVersion: sources.tanzu.vmware.com/v1alpha1
kind: HorizonSource
metadata:
name: horizon-source
spec:
sink:
ref:
apiVersion: eventing.knative.dev/v1
kind: Broker
name: default
namespace: vmware-functions
address: #@ "https://"+horizon
#@ if horizonDisableTls == "True":
skipTLSVerify: true
#@ else:
skipTLSVerify: false
#@ end
secretRef:
name: horizon-creds
serviceAccountName: horizon-source-sa
18 changes: 0 additions & 18 deletions files/configs/ingress/templates/ingressroute-gateway-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ spec:
services:
- name: tinywww
port: 8100
- conditions:
- prefix: /stats/vcenter
pathRewritePolicy:
replacePrefix:
- replacement: /stats
services:
- name: vmware-event-router-vcenter
port: 8082
#@ if webhookEnabled == "True":
- conditions:
- prefix: /stats/webhook
Expand All @@ -62,16 +54,6 @@ spec:
- name: vmware-event-router-webhook
port: 8080
#@ end
#@ if horizonEnabled == "True":
- conditions:
- prefix: /stats/horizon
pathRewritePolicy:
replacePrefix:
- replacement: /stats
services:
- name: vmware-event-router-horizon
port: 8082
#@ end
#@ if vebaUIUsername != "" and vebaUIPassword != "":
- conditions:
- prefix: /veba-ui
Expand Down
32 changes: 32 additions & 0 deletions files/configs/vsphere-source/templates/vsphere-source-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#@ load("@ytt:overlay", "overlay")
#@ load("@ytt:data", "data")

#@ load("@ytt:json", "json")
#@ vcenter = json.decode(data.values.config)["ESCAPED_VCENTER_SERVER"]
#@ vcenterDisableTls = json.decode(data.values.config)["VCENTER_DISABLE_TLS"]
#@ vcenterCheckpointAge = json.decode(data.values.config)["VCENTER_CHECKPOINTING_AGE"]
#@ vcenterCheckpointPeriod = json.decode(data.values.config)["VCENTER_CHECKPOINTING_PERIOD"]

apiVersion: sources.tanzu.vmware.com/v1alpha1
kind: VSphereSource
metadata:
name: vsphere-source
spec:
sink:
ref:
apiVersion: eventing.knative.dev/v1
kind: Broker
name: default
namespace: vmware-functions
address: #@ "https://"+vcenter
checkpointConfig:
maxAgeSeconds: #@ vcenterCheckpointAge
periodSeconds: #@ vcenterCheckpointPeriod
#@ if vcenterDisableTls == "True":
skipTLSVerify: true
#@ else:
skipTLSVerify: false
#@ end
secretRef:
name: vsphere-creds
serviceAccountName: vsphere-source-sa
50 changes: 50 additions & 0 deletions files/downloads/tanzu-sources/overlay.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#@ load("@ytt:overlay", "overlay")
#@ load("@ytt:data", "data")

#@ load("@ytt:json", "json")
#@ tanzuSourcesDebug = json.decode(data.values.config)["TANZU_SOURCES_DEBUG"]

#@ def updates():
#@ if tanzuSourcesDebug == "True":
level: "debug"
#@ end
#@ end

#@overlay/match by=overlay.subset({"kind":"Deployment", "metadata": {"name": "horizon-source-controller", "namespace": "vmware-sources"}})
---
spec:
template:
spec:
containers:
#@overlay/match by=overlay.all, expects="1+"
-
#@overlay/match missing_ok=True
imagePullPolicy: IfNotPresent

#@overlay/match by=overlay.subset({"kind":"Deployment", "metadata": {"name": "horizon-source-webhook", "namespace": "vmware-sources"}})
---
spec:
template:
spec:
containers:
#@overlay/match by=overlay.all, expects="1+"
-
#@overlay/match missing_ok=True
imagePullPolicy: IfNotPresent

#@overlay/match by=overlay.subset({"kind":"Deployment", "metadata": {"name": "vsphere-source-webhook", "namespace": "vmware-sources"}})
---
spec:
template:
spec:
containers:
#@overlay/match by=overlay.all, expects="1+"
-
#@overlay/match missing_ok=True
imagePullPolicy: IfNotPresent

#@overlay/match by=overlay.subset({"metadata":{"name":"config-logging"}}), expects="1+"
---
data:
#@overlay/replace via=lambda a,_: json.encode(overlay.apply(json.decode(a), updates()), indent=2)
zap-logger-config:
2 changes: 1 addition & 1 deletion files/setup-01-os.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2021 VMware, Inc. All rights reserved.
# Copyright 2023 VMware, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2

# OS Specific Settings where ordering does not matter
Expand Down
2 changes: 1 addition & 1 deletion files/setup-010-veba-ui.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2021 VMware, Inc. All rights reserved.
# Copyright 2023 VMware, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2

# Setup Knative UI
Expand Down
2 changes: 1 addition & 1 deletion files/setup-011-fluentbit.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2021 VMware, Inc. All rights reserved.
# Copyright 2023 VMware, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2

# Setup FluentBit
Expand Down
2 changes: 1 addition & 1 deletion files/setup-012-cadvisor.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2021 VMware, Inc. All rights reserved.
# Copyright 2023 VMware, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2

# Setup Google cAdvisor
Expand Down
2 changes: 1 addition & 1 deletion files/setup-02-proxy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2021 VMware, Inc. All rights reserved.
# Copyright 2023 VMware, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2

# Setup Network Proxy for both OS and Containerd
Expand Down
2 changes: 1 addition & 1 deletion files/setup-03-network.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2021 VMware, Inc. All rights reserved.
# Copyright 2023 VMware, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2

# Setup Networking
Expand Down
2 changes: 1 addition & 1 deletion files/setup-04-kubernetes.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2021 VMware, Inc. All rights reserved.
# Copyright 2023 VMware, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2

# Setup Containerd and Kubernetes
Expand Down
21 changes: 18 additions & 3 deletions files/setup-05-knative.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2021 VMware, Inc. All rights reserved.
# Copyright 2023 VMware, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2

# Setup Knative
Expand All @@ -10,6 +10,7 @@ echo -e "\e[92mDeploying Knative Serving ..." > /dev/console
kubectl apply -f /root/download/serving-crds.yaml
kubectl apply -f /root/download/serving-core.yaml
kubectl wait deployment --all --timeout=${KUBECTL_WAIT} --for=condition=Available -n knative-serving

kubectl apply -f /root/download/knative-contour.yaml
kubectl apply -f /root/download/net-contour.yaml
kubectl patch configmap/config-network --namespace knative-serving --type merge --patch '{"data":{"ingress.class":"contour.ingress.networking.knative.dev"}}'
Expand All @@ -19,7 +20,7 @@ kubectl wait deployment --all --timeout=${KUBECTL_WAIT} --for=condition=Availabl
echo -e "\e[92mDeploying Knative Eventing ..." > /dev/console
kubectl apply -f /root/download/eventing-crds.yaml
kubectl apply -f /root/download/eventing-core.yaml
kubectl wait pod --timeout=${KUBECTL_WAIT} --for=condition=Ready -l '!job-name' -n knative-eventing
kubectl wait deployment --all --timeout=${KUBECTL_WAIT} --for=condition=Available -n knative-eventing

echo -e "\e[92mDeploying RabbitMQ Cluster Operator ..." > /dev/console
kubectl apply -f /root/download/cluster-operator.yml
Expand All @@ -42,6 +43,7 @@ RABBITMQ_CONFIG_TEMPLATE=/root/config/knative/templates/rabbit-template.yaml
RABBITMQ_CONFIG=/root/config/knative/rabbit.yaml
ytt --data-value-file bom=${VEBA_BOM_FILE} -f ${RABBITMQ_CONFIG_TEMPLATE} > ${RABBITMQ_CONFIG}
kubectl apply -f ${RABBITMQ_CONFIG}
kubectl wait --for=condition=Ready broker/default --timeout=${KUBECTL_WAIT} -n vmware-functions

echo -e "\e[92mDeploying Sockeye ..." > /dev/console

Expand All @@ -55,4 +57,17 @@ SOCKEYE_CONFIG=/root/config/knative/sockeye.yaml
# Apply YTT overlay
ytt --data-value-file bom=${VEBA_BOM_FILE} -f ${SOCKEYE_TEMPLATE} > ${SOCKEYE_CONFIG}

kubectl -n vmware-functions apply -f ${SOCKEYE_CONFIG}
kubectl -n vmware-functions apply -f ${SOCKEYE_CONFIG}

# Install Tanzu Sources for Knative
echo -e "\e[92mDeploying Tanzu Sources for Knative ..." > /dev/console
TANZU_SOURCES_TEMPLATE=/root/download/tanzu-sources/templates/tanzu-sources-release.yaml
TANZU_SOURCES_OVERLAY=/root/download/tanzu-sources/overlay.yaml
TANZU_SOURCES_CONFIG=/root/download/tanzu-sources-release.yaml
ytt --data-value-file config=${VEBA_CONFIG_FILE} -f ${TANZU_SOURCES_OVERLAY} -f ${TANZU_SOURCES_TEMPLATE} > ${TANZU_SOURCES_CONFIG}
kubectl apply -f ${TANZU_SOURCES_CONFIG}

# Wait for all controllers/webhook to be ready
kubectl wait --for=condition=ready pod -l app=horizon-source-controller --timeout=${KUBECTL_WAIT} -n vmware-sources
kubectl wait --for=condition=ready pod -l app=horizon-source-webhook --timeout=${KUBECTL_WAIT} -n vmware-sources
kubectl wait --for=condition=ready pod -l app=vsphere-source-webhook --timeout=${KUBECTL_WAIT} -n vmware-sources
25 changes: 0 additions & 25 deletions files/setup-06-event-processor.sh

This file was deleted.

25 changes: 25 additions & 0 deletions files/setup-06-horizon-sources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
# Copyright 2023 VMware, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2

# Setup Horizon Sources

set -euo pipefail

# Create Horizon Secret
echo -e "\e[92mCreating Horizon Secret ..." > /dev/console
kubectl -n vmware-functions create secret generic horizon-creds --from-literal=domain=${HORIZON_DOMAIN} --from-literal=username=${HORIZON_USERNAME} --from-literal=password=${HORIZON_PASSWORD}

# Create vSphere Source
echo -e "\e[92mCreating Horizon Source ..." > /dev/console

echo -e "\e[92mCreating Horizon ServiceAccount ..." > /dev/console
kubectl -n vmware-functions create sa horizon-source-sa

HORIZON_SOURCE_CONFIG_TEMPLATE=/root/config/horizon-source/templates/horizon-source-template.yml
HORIZON_SOURCE_CONFIG=/root/config/horizon-source/horizon-source.yml

ytt --data-value-file config=${VEBA_CONFIG_FILE} -f ${HORIZON_SOURCE_CONFIG_TEMPLATE} > ${HORIZON_SOURCE_CONFIG}

kubectl -n vmware-functions create -f ${HORIZON_SOURCE_CONFIG}
kubectl wait --for=condition=Available deploy/horizon-source-adapter --timeout=${KUBECTL_WAIT} -n vmware-functions
Loading

0 comments on commit 9ba9cdc

Please sign in to comment.