Skip to content

Commit

Permalink
Add kustomization
Browse files Browse the repository at this point in the history
  • Loading branch information
heanlan committed Feb 19, 2022
1 parent caebd2a commit 4fb8f1a
Show file tree
Hide file tree
Showing 19 changed files with 4,992 additions and 114 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/upload_release_assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ jobs:
asset_path: ./assets/flow-aggregator.yml
asset_name: flow-aggregator.yml
asset_content_type: application/octet-stream
- name: Upload flow-visibility.yaml
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./assets/flow-visibility.yaml
asset_name: flow-visibility.yaml
asset_content_type: application/octet-stream
- name: Upload antrea-agent-windows-x86_64.exe
uses: actions/upload-release-asset@v1
env:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ manifest:
$(CURDIR)/hack/generate-manifest-octant.sh --mode dev > build/yamls/antrea-octant.yml
$(CURDIR)/hack/generate-manifest-windows.sh --mode dev > build/yamls/antrea-windows.yml
$(CURDIR)/hack/generate-manifest-flow-aggregator.sh --mode dev > build/yamls/flow-aggregator.yml
$(CURDIR)/hack/generate-manifest-flow-visibility.sh > build/yamls/flow-visibility.yaml

.PHONY: manifest-scale
manifest-scale:
Expand Down
4,803 changes: 4,803 additions & 0 deletions build/yamls/flow-visibility.yaml

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions build/yamls/flow-visibility/base/clickhouse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
name: clickhouse
labels:
app: clickhouse
spec:
configuration:
clusters:
- name: "clickhouse"
layout:
shardsCount: 1
replicasCount: 1
defaults:
templates:
podTemplate: pod-template
templates:
podTemplates:
- name: pod-template
spec:
containers:
- name: clickhouse
image: yandex/clickhouse-server:21.11
volumeMounts:
- name: clickhouse-configmap-volume
mountPath: /docker-entrypoint-initdb.d
volumes:
- name: clickhouse-configmap-volume
configMap:
name: $(CH_CONF)
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
apiVersion: v1
kind: Namespace
metadata:
name: flow-visibility
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: grafana
Expand Down Expand Up @@ -76,41 +81,6 @@ stringData:
username: clickhouse_operator
password: clickhouse_operator_password
---
apiVersion: v1
kind: ConfigMap
metadata:
name: grafana-datasource
data:
datasource.yaml: |-
apiVersion: 1
datasources:
- name: ClickHouse
type: grafana-clickhouse-datasource
access: proxy
url: http://clickhouse-clickhouse.flow-visibility.svc:8123
editable: true
jsonData:
server: clickhouse-clickhouse.flow-visibility.svc
port: 9000
username: $CH_USERNAME
secureJsonData:
password: $CH_PASSWORD
---
apiVersion: v1
kind: ConfigMap
metadata:
name: grafana-dashboard-provider
data:
dashboard.yaml: |-
apiVersion: 1
providers:
- name: grafana-dashboards
folder: ''
type: file
allowUiUpdates: true
options:
path: /var/lib/grafana/dashboards
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -178,7 +148,7 @@ spec:
- mountPath: /data
name: grafana-pv
- mountPath: /etc/grafana/provisioning/datasources
name: grafana-datasources
name: grafana-datasource-provider
- mountPath: /etc/grafana/provisioning/dashboards
name: grafana-dashboard-provider
- mountPath: /var/lib/grafana/dashboards
Expand All @@ -187,9 +157,9 @@ spec:
- name: grafana-pv
persistentVolumeClaim:
claimName: grafana-pvc
- name: grafana-datasources
- name: grafana-datasource-provider
configMap:
name: grafana-datasource
name: grafana-datasource-provider
- name: grafana-dashboard-provider
configMap:
name: grafana-dashboard-provider
Expand All @@ -209,35 +179,4 @@ spec:
selector:
app: grafana
sessionAffinity: None
type: LoadBalancer
---
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
name: clickhouse
labels:
app: clickhouse
spec:
configuration:
clusters:
- name: "clickhouse"
layout:
shardsCount: 1
replicasCount: 1
defaults:
templates:
podTemplate: pod-template
templates:
podTemplates:
- name: pod-template
spec:
containers:
- name: clickhouse
image: yandex/clickhouse-server:20.7
volumeMounts:
- name: clickhouse-configmap-volume
mountPath: /docker-entrypoint-initdb.d
volumes:
- name: clickhouse-configmap-volume
configMap:
name: clickhouse-mounted-configmap
type: LoadBalancer
41 changes: 41 additions & 0 deletions build/yamls/flow-visibility/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: flow-visibility

resources:
- clickhouse.yaml
- grafana.yaml

configMapGenerator:
- name: grafana-datasource-provider
files:
- provisioning/datasources/datasource_provider.yaml
- name: grafana-dashboard-provider
files:
- provisioning/dashboards/dashboard_provider.yaml
- name: clickhouse-mounted-configmap
namespace: flow-visibility
files:
- provisioning/datasources/create_table.sh
- name: grafana-dashboard-config
files:
- provisioning/dashboards/flow_records_dashboard.json
- provisioning/dashboards/pod_to_pod_dashboard.json
- provisioning/dashboards/pod_to_service_dashboard.json
- provisioning/dashboards/pod_to_external_dashboard.json
- provisioning/dashboards/node_to_node_dashboard.json
- provisioning/dashboards/networkpolicy_allow_dashboard.json

# CH_CONF exports the value in `metadata.name` from `ConfigMap` named `clickhouse-mounted-configmap`,
# which is used for inserting the value to a CRD for an object of kind `ClickHouseInstallation`
vars:
- name: CH_CONF
objref:
kind: ConfigMap
name: clickhouse-mounted-configmap
apiVersion: v1
fieldref:
fieldpath: metadata.name

configurations:
- kustomize-config.yaml
3 changes: 3 additions & 0 deletions build/yamls/flow-visibility/base/kustomize-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
varReference:
- path: spec/templates/podTemplates/spec/volumes/configMap/name
kind: ClickHouseInstallation
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: 1
providers:
- name: grafana-dashboards
folder: ''
type: file
allowUiUpdates: true
options:
path: /var/lib/grafana/dashboards
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -e
clickhouse client -n <<-EOSQL
clickhouse client -n -h 127.0.0.1 <<-EOSQL
CREATE TABLE IF NOT EXISTS flows (
timeInserted DateTime DEFAULT now(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: 1
datasources:
- name: ClickHouse
type: grafana-clickhouse-datasource
access: proxy
url: http://clickhouse-clickhouse.flow-visibility.svc:8123
editable: true
jsonData:
server: clickhouse-clickhouse.flow-visibility.svc
port: 9000
username: $CH_USERNAME
secureJsonData:
password: $CH_PASSWORD
43 changes: 0 additions & 43 deletions build/yamls/flow-visibility/start-flow-visibility.sh

This file was deleted.

72 changes: 72 additions & 0 deletions hack/generate-manifest-flow-visibility.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bash

# Copyright 2022 Antrea Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -eo pipefail

function echoerr {
>&2 echo "$@"
}

_usage="Usage: $0 [--help|-h]
Generate a YAML manifest for the Clickhouse-Grafana Flow-visibility Solution, using Kustomize, and
print it to stdout.
This tool uses kustomize (https://github.com/kubernetes-sigs/kustomize) to generate manifests for
Clickhouse-Grafana Flow-visibility Solution. You can set the KUSTOMIZE environment variable to the
path of the kustomize binary you want us to use. Otherwise we will look for kustomize in your PATH
and your GOPATH. If we cannot find kustomize there, we will try to install it."

function print_usage {
echoerr "$_usage"
}

function print_help {
echoerr "Try '$0 --help' for more information."
}

while [[ $# -gt 0 ]]
do
key="$1"

case $key in
-h|--help)
print_usage
exit 0
;;
*) # unknown option
echoerr "Unknown option $1"
exit 1
;;
esac
done

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

source $THIS_DIR/verify-kustomize.sh

if [ -z "$KUSTOMIZE" ]; then
KUSTOMIZE="$(verify_kustomize)"
elif ! $KUSTOMIZE version > /dev/null 2>&1; then
echoerr "$KUSTOMIZE does not appear to be a valid kustomize binary"
print_help
exit 1
fi

KUSTOMIZATION_DIR=$THIS_DIR/../build/yamls/flow-visibility

cd $KUSTOMIZATION_DIR/base

$KUSTOMIZE build
2 changes: 2 additions & 0 deletions hack/release/prepare-assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,6 @@ export IMG_NAME=projects.registry.vmware.com/antrea/antrea-windows
export IMG_NAME=projects.registry.vmware.com/antrea/flow-aggregator
./hack/generate-manifest-flow-aggregator.sh --mode release > "$OUTPUT_DIR"/flow-aggregator.yml

./hack/generate-manifest-flow-visibility.sh > "$OUTPUT_DIR"/flow-visibility.yaml

ls "$OUTPUT_DIR" | cat

0 comments on commit 4fb8f1a

Please sign in to comment.