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: parameterize the helm chart namespace value #351

Merged
merged 7 commits into from
Sep 18, 2023
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
12 changes: 9 additions & 3 deletions charts/hedera-network/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
dependencies:
- name: hedera-explorer
repository: ""
version: 0.2.0
- name: hedera-mirror
repository: https://hashgraph.github.io/hedera-mirror-node/charts
version: 0.86.0
- name: tenant
repository: https://operator.min.io/
version: 5.0.6
digest: sha256:d1145f65bba0cb295b33e94b0fdc79d80bf06d22cf2606061d0c1462800d3ae7
generated: "2023-08-09T09:52:59.515466+10:00"
version: 5.0.7
digest: sha256:cf355b295abceb5814ef57d3e146ec9d4e8db7365a700079d683bd5f766ad374
generated: "2023-09-16T13:47:19.087992+10:00"
1 change: 1 addition & 0 deletions charts/hedera-network/templates/configmaps/envoy-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: envoy-proxy-cm-{{ $node.name }}
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
data:
envoy.yaml: |
{{- tpl ($.Files.Get "config-files/envoy.yaml") (dict "nodeConfig" $node "Template" $.Template) | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: haproxy-cm-{{ $node.name }}
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
data:
haproxy.cfg: |
{{- tpl ($.Files.Get "config-files/haproxy.cfg") (dict "nodeConfig" $node "Template" $.Template) | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: otel-collector-cm
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
data:
config.yaml: |
{{- tpl (.Files.Get "config-files/otel-collector-config.yaml") ( dict "otelDefaults" $.Values.defaults.sidecars.otelCollector "Template" $.Template ) | nindent 4 }}
1 change: 1 addition & 0 deletions charts/hedera-network/templates/configmaps/test-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: test-cm
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
data:
{{- $total_nodes := len $.Values.hedera.nodes -}}
{{- range $path, $_ := .Files.Glob "tests/*.*" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
name: envoy-grpc-web-route-{{ $node.name }}
namespace: default
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
labels:
fullstack.hedera.com/type: http-route
spec:
Expand Down
4 changes: 2 additions & 2 deletions charts/hedera-network/templates/gateway-api/gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: gateway.networking.k8s.io/v1beta1
kind: GatewayClass
metadata:
name: {{ $.Values.gatewayApi.gatewayClass.name }}
namespace: default
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
labels:
fullstack.hedera.com/type: gateway-class
spec:
Expand All @@ -15,7 +15,7 @@ apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
name: {{ $.Values.gatewayApi.gateway.name }}
namespace: default
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
labels:
fullstack.hedera.com/type: gateway
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apiVersion: gateway.networking.k8s.io/v1alpha2
kind: TCPRoute
metadata:
name: haproxy-grpc-route-{{ $node.name }}
namespace: default
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
labels:
fullstack.hedera.com/type: tcp-route
fullstack.hedera.com/nodeName: {{ $node.name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apiVersion: gateway.networking.k8s.io/v1alpha2
kind: TCPRoute
metadata:
name: node-grpc-route-{{ $node.name }}
namespace: default
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
labels:
fullstack.hedera.com/type: tcp-route
fullstack.hedera.com/nodeName: {{ $node.name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
name: network-{{ $node.name }}
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
labels:
app: network-{{ $node.name }}
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: envoy-proxy-{{ $node.name }}
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
spec:
replicas: 1
selector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: haproxy-{{ $node.name }}
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
spec:
replicas: 1
selector:
Expand Down
6 changes: 3 additions & 3 deletions charts/hedera-network/templates/rbac/pod-monitor-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: pod-monitoring-role
namespace: {{ .Values.namespace }}
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
rules:
- apiGroups: [ "" ]
resources:
Expand Down Expand Up @@ -31,11 +31,11 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: pod-monitoring-role-binding
namespace: {{ .Values.namespace }}
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
subjects:
- kind: ServiceAccount
name: pod-monitor
namespace: {{ .Values.namespace }}
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
roleRef:
kind: ClusterRole
name: pod-monitoring-role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: pod-monitor
namespace: {{ .Values.namespace }}
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: v1
kind: Secret
metadata:
name: backup-uploader-secrets
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
type: Opaque
data:
S3_ACCESS_KEY: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: v1
kind: Secret
metadata:
name: otel-collector-secrets
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
type: Opaque
data:
S3_ACCESS_KEY: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ apiVersion: v1
kind: Secret
metadata:
name: minio-secrets
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
type: Opaque
data:
config.env: {{ $minio_config_env | b64enc }}
Expand Down
1 change: 1 addition & 0 deletions charts/hedera-network/templates/services/envoy-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ apiVersion: v1
kind: Service
metadata:
name: envoy-proxy-{{ $node.name }}-svc
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
labels:
fullstack.hedera.com/type: envoy-proxy-svc
fullstack.hedera.com/node-name: {{ $node.name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ apiVersion: v1
kind: Service
metadata:
name: haproxy-{{ $node.name }}-svc
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
labels:
fullstack.hedera.com/type: haproxy-svc
fullstack.hedera.com/node-name: {{ $node.name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apiVersion: v1
kind: Service
metadata:
name: network-{{ $nodeConfig.name }}-svc
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
labels:
fullstack.hedera.com/type: network-node-svc
fullstack.hedera.com/node-name: {{ $nodeConfig.name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: network-node-monitor
namespace: {{ default $.Release.Namespace $.Values.global.namespaceOverride }}
labels:
fullstack.hedera.com/type: network-node-svc-monitor
spec:
Expand Down
10 changes: 8 additions & 2 deletions charts/hedera-network/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# WARNING: Use double quotes for all values. This is because we need to be careful about booleans.

global:
namespaceOverride: ""

# cloud configuration
cloud:
minio:
Expand Down Expand Up @@ -62,7 +65,6 @@ gatewayApi:
route:
hostname: "{{ .node.name }}.fst.local"

namespace: default

# default settings for a single node
# This default configurations can be overridden for each node in the hedera.nodes section.
Expand Down Expand Up @@ -197,7 +199,7 @@ defaults:
insecure: true
prometheusRemoteWrite:
enable: "false"
endpoint: "http://prometheus.default.svc:9090/api/v1/write"
endpoint: "" # e.g. http://prometheus.<NAMESPACE>.svc:9090/api/v1/write
tls:
insecure: true

Expand All @@ -223,6 +225,8 @@ minio-server:
requestAutoCert: false

hedera-mirror-node:
global:
namespaceOverride: "{{ tpl (.Values.global.namespaceOverride | toString) }}"
# importer is a component of the hedera mirror node
# config for subchart hedera-mirror/importer
importer:
Expand All @@ -249,6 +253,8 @@ hedera-mirror-node:
# for s3 configuration of mirror node look at uploader-mirror-secrets.yaml

hedera-explorer:
global:
namespaceOverride: "{{ tpl (.Values.global.namespaceOverride | toString) }}"
# The hedera explorer UI /api url will proxy all request to mirror node
#
# Without this we would need to expose the mirror node rest API publicly and specify its public url in the network config below
Expand Down
15 changes: 4 additions & 11 deletions dev/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ SHELLOPTS:=$(if $(SHELLOPTS),$(SHELLOPTS):)pipefail:errexit
ci-test

# Setup variables
CLUSTER_NAME ?="fst"
SCRIPTS_DIR=$(PWD)/scripts
CHART_DIR=$(PWD)/../charts/hedera-network
SCRIPT_NAME=direct-install.sh
Expand All @@ -38,17 +37,15 @@ DOCKER_SCRIPT="docker.sh"

.PHONY: setup
setup:
rm -f "${TMP_DIR}/"*.*
cp "${SCRIPTS_DIR}/template.env" "${TMP_DIR}/.env"
source "${SCRIPTS_DIR}/main.sh" && setup

.PHONY: setup-cluster
setup-cluster:
echo "Cluster name: ${CLUSTER_NAME}" && \
source "${SCRIPTS_DIR}/main.sh" && setup_cluster "${CLUSTER_NAME}"
source "${SCRIPTS_DIR}/main.sh" && setup_cluster

.PHONY: destroy-cluster
destroy-cluster:
kind delete cluster -n fst
source "${SCRIPTS_DIR}/main.sh" && destroy_cluster

.PHONY: install-chart
install-chart:
Expand Down Expand Up @@ -155,12 +152,8 @@ destroy-gateway-api:
source "${SCRIPTS_DIR}/${GATEWAY_API_SCRIPT}" && destroy_envoy_gateway_api

######################################### Telemetry #################################
.PHONY: fetch-prometheus-operator-bundle
fetch-prometheus-operator-bundle:
source "${SCRIPTS_DIR}/${TELEMETRY_SCRIPT}" && fetch-prometheus-operator-bundle

.PHONY: deploy-prometheus-operator
deploy-prometheus-operator: fetch-prometheus-operator-bundle
deploy-prometheus-operator:
source "${SCRIPTS_DIR}/${TELEMETRY_SCRIPT}" && deploy-prometheus-operator

.PHONY: destroy-prometheus-operator
Expand Down
15 changes: 6 additions & 9 deletions dev/scripts/docker.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
#!/usr/bin/env bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
readonly SCRIPT_DIR
readonly DOCKERFILE_DIR="${SCRIPT_DIR}/../../docker"
readonly LOCAL_DOCKER_REGISTRY="docker.fst.local" # same as in dev/ci/ci-values.yaml
readonly LOCAL_DOCKER_IMAGE_TAG="local"
CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
source "${CUR_DIR}/env.sh"
setup_kubectl_context

readonly KUBECTL_BATS_IMAGE="${LOCAL_DOCKER_REGISTRY}/kubectl-bats:${LOCAL_DOCKER_IMAGE_TAG}"

function build_kubectl_bats() {
local cluster_name=$1
local cluster_name=$1
[[ -z "${cluster_name}" ]] && echo "ERROR: Cluster name is required" && return 1
[[ -z "${CLUSTER_NAME}" ]] && echo "ERROR: [build_kubectl_bats] Cluster name is required" && return 1

echo ""
echo "Building kubectl-bats image"
echo "-----------------------------------------------------------------------------------------------------"
cd "${DOCKERFILE_DIR}/kubectl-bats" && docker build -t "${KUBECTL_BATS_IMAGE}" .
kind load docker-image ${KUBECTL_BATS_IMAGE} -n "${cluster_name}"
kind load docker-image "${KUBECTL_BATS_IMAGE}" -n "${CLUSTER_NAME}"
}
67 changes: 67 additions & 0 deletions dev/scripts/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"

readonly SCRIPT_DIR
readonly TMP_DIR="${SCRIPT_DIR}/../temp"
readonly CHART_DIR="${SCRIPT_DIR}/../../charts/hedera-network"


# telemetry related env variables
readonly GATEWAY_API_DIR="${SCRIPT_DIR}/../gateway-api"
readonly TELEMETRY_DIR="${SCRIPT_DIR}/../telemetry"
readonly PROMETHEUS_DIR="${TELEMETRY_DIR}/prometheus"
readonly PROMETHEUS_VERSION=v0.67.1
readonly PROMETHEUS_OPERATOR_YAML="${PROMETHEUS_DIR}/prometheus-operator.yaml"
readonly PROMETHEUS_YAML="${PROMETHEUS_DIR}/prometheus.yaml"
readonly PROMETHEUS_RBAC_YAML="${PROMETHEUS_DIR}/prometheus-rbac.yaml"
readonly PROMETHEUS_EXAMPLE_APP_YAML="${PROMETHEUS_DIR}/example-app.yaml"

# docker build related env variables
readonly DOCKERFILE_DIR="${SCRIPT_DIR}/../../docker"
readonly LOCAL_DOCKER_REGISTRY="docker.fst.local" # same as in dev/ci/ci-values.yaml
readonly LOCAL_DOCKER_IMAGE_TAG="local"

function setup_temp_dir() {
if [ ! -f "${TMP_DIR}/.env" ]; then \
echo "Creating .env file from template.env"
cp "${SCRIPT_DIR}/template.env" "${TMP_DIR}/.env"
echo "File list in ${TMP_DIR}"
ls -la "${TMP_DIR}"
fi
}

function load_env_file() {
if [ -f "${TMP_DIR}/.env" ]; then \
set -a
# shellcheck source=./../temp/.env
source "${TMP_DIR}/.env"
set +a
fi
}

function setup_kubectl_context() {
load_env_file
[[ -z "${CLUSTER_NAME}" ]] && echo "ERROR: Cluster name is required" && return 1
[[ -z "${NAMESPACE}" ]] && echo "ERROR: Namespace name is required" && return 1

kubectl get ns "${NAMESPACE}" &>/dev/null
if [[ $? -ne 0 ]]; then
kubectl create ns "${NAMESPACE}"
fi

echo "List of namespaces:"
kubectl get ns

echo "Setting kubectl context..."
kubectl config use-context "kind-${CLUSTER_NAME}"
kubectl config set-context --current --namespace="${NAMESPACE}"
kubectl config get-contexts
}

function setup() {
setup_temp_dir
load_env_file
}

setup
7 changes: 3 additions & 4 deletions dev/scripts/gateway.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env bash

GATEWAY_API_VERSION="${GATEWAY_API_VERSION:-v0.7.1}"
CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
source "${CUR_DIR}/env.sh"

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
readonly GATEWAY_API_DIR="${SCRIPT_DIR}/../gateway-api"
readonly SCRIPT_DIR
GATEWAY_API_VERSION="${GATEWAY_API_VERSION:-v0.7.1}"

function deploy_haproxy_ingress() {
deploy_gateway_api_crd
Expand Down
Loading