Skip to content

Commit 729b99a

Browse files
Merge pull request #1048 from karelyatin/OSPRH-12627
Add support to setup network observability
2 parents 4e8b811 + 3f2c0d0 commit 729b99a

File tree

5 files changed

+340
-0
lines changed

5 files changed

+340
-0
lines changed

Makefile

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,20 @@ REDIS ?= config/samples/redis_v1beta1_redis.yaml
536536
REDIS_CR ?= ${OPERATOR_BASE_DIR}/infra-operator-redis/${REDIS}
537537
REDIS_DEPL_IMG ?= unused
538538

539+
# Loki
540+
LOKI_NAMESPACE ?= openshift-operators-redhat
541+
LOKI_OPERATOR_GROUP ?= openshift-operators-redhat-loki
542+
LOKI_SUBSCRIPTION ?= loki-operator
543+
LOKI_DEPLOY_NAMESPACE ?= netobserv
544+
LOKI_DEPLOY_MODE ?= openshift-network
545+
LOKI_DEPLOY_SIZE ?= 1x.demo
546+
547+
# Netobserv
548+
NETOBSERV_NAMESPACE ?= openshift-netobserv-operator
549+
NETOBSERV_OPERATOR_GROUP ?= openshift-netobserv-operator-net
550+
NETOBSERV_SUBSCRIPTION ?= netobserv-operator
551+
NETOBSERV_DEPLOY_NAMESPACE ?= ${LOKI_DEPLOY_NAMESPACE}
552+
539553
# target vars for generic operator install info 1: target name , 2: operator name
540554
define vars
541555
${1}: export NAMESPACE=${NAMESPACE}
@@ -2549,6 +2563,87 @@ metallb_cleanup: ## deletes the operator, but does not cleanup the service resou
25492563
bash scripts/operator-cleanup.sh
25502564
${CLEANUP_DIR_CMD} ${OPERATOR_DIR}
25512565

2566+
##@ LOKI
2567+
.PHONY: loki
2568+
loki: export NAMESPACE=${LOKI_NAMESPACE}
2569+
loki: export OPERATOR_GROUP=${LOKI_OPERATOR_GROUP}
2570+
loki: export SUBSCRIPTION=${LOKI_SUBSCRIPTION}
2571+
loki: ## installs loki operator in the openshift-operators-redhat namespace
2572+
$(eval $(call vars,$@,loki))
2573+
bash scripts/gen-namespace.sh
2574+
oc apply -f ${OUT}/${NAMESPACE}/namespace.yaml
2575+
timeout $(TIMEOUT) bash -c "while ! (oc get project.v1.project.openshift.io ${NAMESPACE}); do sleep 1; done"
2576+
bash scripts/gen-olm-loki.sh
2577+
oc apply -f ${OPERATOR_DIR}
2578+
timeout ${TIMEOUT} bash -c "while ! (oc get deployments/loki-operator-controller-manager -n ${NAMESPACE}); do sleep 10; done"
2579+
oc wait deployments/loki-operator-controller-manager -n ${NAMESPACE} --for condition=Available --timeout=${TIMEOUT}
2580+
2581+
.PHONY: loki_cleanup
2582+
loki_cleanup: export OPERATOR_NAMESPACE=${LOKI_NAMESPACE}
2583+
loki_cleanup: ## deletes the operator, but does not cleanup the service resources
2584+
$(eval $(call vars,$@,loki))
2585+
bash scripts/operator-cleanup.sh
2586+
${CLEANUP_DIR_CMD} ${OPERATOR_DIR}
2587+
2588+
##@ LOKI_DEPLOY
2589+
.PHONY: loki_deploy
2590+
loki_deploy: export NAMESPACE=${LOKI_DEPLOY_NAMESPACE}
2591+
loki_deploy: export SIZE=${LOKI_DEPLOY_SIZE}
2592+
loki_deploy: export MODE=${LOKI_DEPLOY_MODE}
2593+
loki_deploy: namespace ## installs Lokistack in the netobserv namespace
2594+
$(eval $(call vars,$@,loki))
2595+
bash scripts/gen-lokistack.sh
2596+
oc apply -f ${DEPLOY_DIR}/lokisecret.yaml
2597+
oc apply -f ${DEPLOY_DIR}/lokistack.yaml
2598+
timeout ${TIMEOUT} bash -c "while ! (oc get lokistack/loki -n ${NAMESPACE}); do sleep 10; done"
2599+
oc wait lokistack/loki --for condition=Ready=True -n ${NAMESPACE} --timeout=${TIMEOUT}
2600+
2601+
.PHONY: loki_deploy_cleanup
2602+
loki_deploy_cleanup: export NAMESPACE=${LOKI_DEPLOY_NAMESPACE}
2603+
loki_deploy_cleanup: ## removes Lokistack CRs in the netobserv namespace
2604+
oc delete lokistack --all=true -n ${NAMESPACE}
2605+
2606+
##@ NETOBSERV
2607+
.PHONY: netobserv
2608+
netobserv: export NAMESPACE=${NETOBSERV_NAMESPACE}
2609+
netobserv: export OPERATOR_GROUP=${NETOBSERV_OPERATOR_GROUP}
2610+
netobserv: export SUBSCRIPTION=${NETOBSERV_SUBSCRIPTION}
2611+
netobserv: ## installs netobserv operator in the openshift-netobserv namespace
2612+
$(eval $(call vars,$@,netobserv))
2613+
bash scripts/gen-namespace.sh
2614+
oc apply -f ${OUT}/${NAMESPACE}/namespace.yaml
2615+
timeout $(TIMEOUT) bash -c "while ! (oc get project.v1.project.openshift.io ${NAMESPACE}); do sleep 1; done"
2616+
bash scripts/gen-olm-netobserv.sh
2617+
oc apply -f ${OPERATOR_DIR}
2618+
timeout ${TIMEOUT} bash -c "while ! (oc get deployments/netobserv-controller-manager -n ${NAMESPACE}); do sleep 10; done"
2619+
oc wait deployments/netobserv-controller-manager -n ${NAMESPACE} --for condition=Available --timeout=${TIMEOUT}
2620+
2621+
.PHONY: netobserv_cleanup
2622+
netobserv_cleanup: export OPERATOR_NAMESPACE=${NETOBSERV_NAMESPACE}
2623+
netobserv_cleanup: ## deletes the operator, but does not cleanup the service resources
2624+
$(eval $(call vars,$@,network-observability))
2625+
bash scripts/operator-cleanup.sh
2626+
oc delete sub -n ${NETOBSERV_NAMESPACE} netobserv-operator --ignore-not-found=true
2627+
${CLEANUP_DIR_CMD} ${OPERATOR_DIR}
2628+
2629+
##@ NETOBSERV_DEPLOY
2630+
.PHONY: netobserv_deploy
2631+
netobserv_deploy: export NAMESPACE=${NETOBSERV_DEPLOY_NAMESPACE}
2632+
netobserv_deploy: ## installs netobserv CRs in the netobserv namespace
2633+
$(eval $(call vars,$@,netobserv))
2634+
bash scripts/gen-namespace.sh
2635+
oc apply -f ${OUT}/${NAMESPACE}/namespace.yaml
2636+
timeout $(TIMEOUT) bash -c "while ! (oc get project.v1.project.openshift.io ${NAMESPACE}); do sleep 1; done"
2637+
bash scripts/gen-netobserv.sh
2638+
oc apply -f ${DEPLOY_DIR}/flowcollector.yaml
2639+
timeout ${TIMEOUT} bash -c "while ! (oc get flowcollector/cluster -n ${NAMESPACE}); do sleep 10; done"
2640+
oc wait flowcollector/cluster --for condition=Ready=True -n ${NAMESPACE} --timeout=${TIMEOUT}
2641+
2642+
.PHONY: netobserv_deploy_cleanup
2643+
netobserv_deploy_cleanup: export NAMESPACE=${NETOBSERV_DEPLOY_NAMESPACE}
2644+
netobserv_deploy_cleanup: ## removes netobserv CRs in the netobserv namespace
2645+
oc delete flowcollector --all=true -n ${NAMESPACE}
2646+
25522647
##@ MANILA
25532648
.PHONY: manila_prep
25542649
manila_prep: export IMAGE=${MANILA_IMG}

scripts/gen-lokistack.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2024 Red Hat Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
set -ex
17+
18+
if [ -z "${DEPLOY_DIR}" ]; then
19+
echo "Please set DEPLOY_DIR"; exit 1
20+
fi
21+
22+
if [ ! -d ${DEPLOY_DIR} ]; then
23+
mkdir -p ${DEPLOY_DIR}
24+
fi
25+
26+
if [ -z "${NAMESPACE}" ]; then
27+
echo "Please set NAMESPACE"; exit 1
28+
fi
29+
30+
if [ -z "${STORAGE_CLASS}" ]; then
31+
echo "Please set STORAGE_CLASS"; exit 1
32+
fi
33+
34+
if [ -z "${SIZE}" ]; then
35+
echo "Please set SIZE"; exit 1
36+
fi
37+
38+
if [ -z "${MODE}" ]; then
39+
echo "Please set MODE"; exit 1
40+
fi
41+
42+
echo DEPLOY_DIR ${DEPLOY_DIR}
43+
echo NAMESPACE ${NAMESPACE}
44+
echo SIZE ${SIZE}
45+
echo MODE ${MODE}
46+
47+
cat > ${DEPLOY_DIR}/lokisecret.yaml <<EOF_CAT
48+
---
49+
apiVersion: v1
50+
kind: Secret
51+
metadata:
52+
name: loki-s3
53+
namespace: ${NAMESPACE}
54+
stringData:
55+
access_key_id: QUtJQUlPU0ZPRE5ON0VYQU1QTEUK
56+
access_key_secret: d0phbHJYVXRuRkVNSS9LN01ERU5HL2JQeFJmaUNZRVhBTVBMRUtFWQo=
57+
bucketnames: s3-bucket-name
58+
endpoint: https://s3.eu-central-1.amazonaws.com
59+
region: eu-central-1
60+
EOF_CAT
61+
62+
cat > ${DEPLOY_DIR}/lokistack.yaml <<EOF_CAT
63+
---
64+
apiVersion: loki.grafana.com/v1
65+
kind: LokiStack
66+
metadata:
67+
name: loki
68+
namespace: ${NAMESPACE}
69+
spec:
70+
size: ${SIZE}
71+
storage:
72+
schemas:
73+
- version: v12
74+
effectiveDate: '2022-06-01'
75+
secret:
76+
name: loki-s3
77+
type: s3
78+
storageClassName: ${STORAGE_CLASS}
79+
tenants:
80+
mode: ${MODE}
81+
EOF_CAT

scripts/gen-netobserv.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2024 Red Hat Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
set -ex
17+
18+
if [ -z "${DEPLOY_DIR}" ]; then
19+
echo "Please set DEPLOY_DIR"; exit 1
20+
fi
21+
22+
if [ ! -d ${DEPLOY_DIR} ]; then
23+
mkdir -p ${DEPLOY_DIR}
24+
fi
25+
26+
if [ -z "${NAMESPACE}" ]; then
27+
echo "Please set NAMESPACE"; exit 1
28+
fi
29+
30+
echo DEPLOY_DIR ${DEPLOY_DIR}
31+
echo NAMESPACE ${NAMESPACE}
32+
33+
cat > ${DEPLOY_DIR}/flowcollector.yaml <<EOF_CAT
34+
---
35+
apiVersion: flows.netobserv.io/v1beta2
36+
kind: FlowCollector
37+
metadata:
38+
name: cluster
39+
spec:
40+
agent:
41+
ebpf:
42+
sampling: 500
43+
privileged: true
44+
features:
45+
- PacketDrop
46+
- DNSTracking
47+
deploymentModel: Direct
48+
kafka:
49+
sasl:
50+
type: Disabled
51+
tls:
52+
enable: false
53+
insecureSkipVerify: false
54+
loki:
55+
enable: true
56+
mode: LokiStack
57+
lokiStack:
58+
name: loki
59+
namespace: ${NAMESPACE}
60+
EOF_CAT

scripts/gen-olm-loki.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2022 Red Hat Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
set -ex
17+
18+
if [ -z "${OPERATOR_DIR}" ]; then
19+
echo "Please set OPERATOR_DIR"; exit 1
20+
fi
21+
22+
if [ ! -d ${OPERATOR_DIR} ]; then
23+
mkdir -p ${OPERATOR_DIR}
24+
fi
25+
26+
echo OPERATOR_DIR ${OPERATOR_DIR}
27+
28+
cat > ${OPERATOR_DIR}/operatorgroup.yaml <<EOF_CAT
29+
apiVersion: operators.coreos.com/v1
30+
kind: OperatorGroup
31+
metadata:
32+
name: ${OPERATOR_GROUP}
33+
namespace: ${NAMESPACE}
34+
spec:
35+
upgradeStrategy: Default
36+
EOF_CAT
37+
38+
cat > ${OPERATOR_DIR}/subscription.yaml <<EOF_CAT
39+
apiVersion: operators.coreos.com/v1alpha1
40+
kind: Subscription
41+
metadata:
42+
labels:
43+
operators.coreos.com/loki-operator.openshift-operators-redhat: ""
44+
name: ${SUBSCRIPTION}
45+
namespace: ${NAMESPACE}
46+
spec:
47+
channel: stable-6.1
48+
installPlanApproval: Automatic
49+
name: ${SUBSCRIPTION}
50+
source: redhat-operators
51+
sourceNamespace: openshift-marketplace
52+
EOF_CAT

scripts/gen-olm-netobserv.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2022 Red Hat Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
set -ex
17+
18+
if [ -z "${OPERATOR_DIR}" ]; then
19+
echo "Please set OPERATOR_DIR"; exit 1
20+
fi
21+
22+
if [ ! -d ${OPERATOR_DIR} ]; then
23+
mkdir -p ${OPERATOR_DIR}
24+
fi
25+
26+
echo OPERATOR_DIR ${OPERATOR_DIR}
27+
28+
cat > ${OPERATOR_DIR}/operatorgroup.yaml <<EOF_CAT
29+
apiVersion: operators.coreos.com/v1
30+
kind: OperatorGroup
31+
metadata:
32+
name: ${OPERATOR_GROUP}
33+
namespace: ${NAMESPACE}
34+
spec:
35+
upgradeStrategy: Default
36+
EOF_CAT
37+
38+
cat > ${OPERATOR_DIR}/subscription.yaml <<EOF_CAT
39+
apiVersion: operators.coreos.com/v1alpha1
40+
kind: Subscription
41+
metadata:
42+
labels:
43+
operators.coreos.com/netobserv-operator.openshift-netobserv-operator: ""
44+
name: ${SUBSCRIPTION}
45+
namespace: ${NAMESPACE}
46+
spec:
47+
channel: stable
48+
installPlanApproval: Automatic
49+
name: ${SUBSCRIPTION}
50+
source: redhat-operators
51+
sourceNamespace: openshift-marketplace
52+
EOF_CAT

0 commit comments

Comments
 (0)