forked from netobserv/netobserv-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevelopment.mk
More file actions
224 lines (200 loc) · 12.7 KB
/
development.mk
File metadata and controls
224 lines (200 loc) · 12.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
##@ Development helpers
ifeq ("", "$(CSV)")
OPERATOR_NS ?= $(NAMESPACE)
else
OPERATOR_NS ?= openshift-netobserv-operator
endif
.PHONY: deploy-loki
deploy-loki: ## Deploy loki.
@echo -e "\n==> Deploy loki"
kubectl create namespace $(NAMESPACE) --dry-run=client -o yaml | kubectl apply -f -
kubectl config set-context --current --namespace=$(NAMESPACE)
curl -S -L https://raw.githubusercontent.com/netobserv/documents/main/examples/zero-click-loki/1-storage.yaml | kubectl create -f - || true
curl -S -L https://raw.githubusercontent.com/netobserv/documents/main/examples/zero-click-loki/2-loki.yaml | kubectl create -f - || true
kubectl wait --timeout=180s --for=condition=ready pod -l app=loki
-pkill --oldest --full "3100:3100"
ifeq (true, $(PORT_FWD))
-kubectl port-forward --address 0.0.0.0 svc/loki 3100:3100 2>&1 >/dev/null &
@echo -e "\n===> loki endpoint is available on http://localhost:3100\n"
endif
.PHONY: undeploy-loki-tls
undeploy-loki-tls:
@echo -e "\n==> Undeploy tls loki"
kubectl config set-context --current --namespace=$(NAMESPACE)
curl -S -L https://raw.githubusercontent.com/netobserv/documents/main/examples/zero-click-loki/2-loki-tls.yaml | kubectl --ignore-not-found=true delete -f - || true
curl -S -L https://raw.githubusercontent.com/netobserv/documents/main/examples/zero-click-loki/1-storage.yaml | kubectl --ignore-not-found=true delete -f - || true
-pkill --oldest --full "3100:3100"
.PHONY: deploy-loki-tls
deploy-loki-tls:
@echo -e "\n==> Deploy tls loki"
kubectl create namespace $(NAMESPACE) --dry-run=client -o yaml | kubectl apply -f -
kubectl config set-context --current --namespace=$(NAMESPACE)
curl -S -L https://raw.githubusercontent.com/netobserv/documents/main/examples/zero-click-loki/1-storage.yaml | kubectl create -f - || true
curl -S -L https://raw.githubusercontent.com/netobserv/documents/main/examples/zero-click-loki/2-loki-tls.yaml | kubectl create -f - || true
kubectl wait --timeout=180s --for=condition=ready pod -l app=loki
-pkill --oldest --full "3100:3100"
ifeq (true, $(PORT_FWD))
-kubectl port-forward --address 0.0.0.0 svc/loki 3100:3100 2>&1 >/dev/null &
@echo -e "\n===> loki endpoint is available on http://localhost:3100\n"
endif
.PHONY: undeploy-loki
undeploy-loki: ## Undeploy loki.
@echo -e "\n==> Undeploy loki"
kubectl config set-context --current --namespace=$(NAMESPACE)
curl -S -L https://raw.githubusercontent.com/netobserv/documents/main/examples/zero-click-loki/2-loki.yaml | kubectl --ignore-not-found=true delete -f - || true
curl -S -L https://raw.githubusercontent.com/netobserv/documents/main/examples/zero-click-loki/1-storage.yaml | kubectl --ignore-not-found=true delete -f - || true
-pkill --oldest --full "3100:3100"
.PHONY: deploy-kafka
deploy-kafka:
@echo -e "\n==> Deploy default Kafka. Get more help on https://github.com/netobserv/documents/blob/main/kafka.md"
kubectl create namespace $(NAMESPACE) --dry-run=client -o yaml | kubectl apply -f -
curl -s -L "https://raw.githubusercontent.com/netobserv/documents/main/examples/kafka/strimzi-cluster-operator.yaml" | sed -r 's/namespace: (default|myproject)/namespace: $(NAMESPACE)/g' | kubectl apply -n $(NAMESPACE) -f -
kubectl apply -f "https://raw.githubusercontent.com/netobserv/documents/main/examples/kafka/kafka-node-pool.yaml" -n $(NAMESPACE)
kubectl apply -f "https://raw.githubusercontent.com/netobserv/documents/main/examples/kafka/metrics-config.yaml" -n $(NAMESPACE)
curl -s -L "https://raw.githubusercontent.com/netobserv/documents/main/examples/kafka/default.yaml" | envsubst | kubectl apply -n $(NAMESPACE) -f -
kubectl apply -f "https://raw.githubusercontent.com/netobserv/documents/main/examples/kafka/topic.yaml" -n $(NAMESPACE)
kubectl wait --timeout=180s --for=condition=ready kafkatopic network-flows -n $(NAMESPACE)
.PHONY: deploy-kafka-tls
deploy-kafka-tls:
@echo -e "\n==> Deploy Kafka with mTLS. Get more help on https://github.com/netobserv/documents/blob/main/kafka.md"
kubectl create namespace $(NAMESPACE) --dry-run=client -o yaml | kubectl apply -f -
curl -s -L "https://raw.githubusercontent.com/netobserv/documents/main/examples/kafka/strimzi-cluster-operator.yaml" | sed -r 's/namespace: (default|myproject)/namespace: $(NAMESPACE)/g' | kubectl apply -n $(NAMESPACE) -f -
kubectl apply -f "https://raw.githubusercontent.com/netobserv/documents/main/examples/kafka/kafka-node-pool.yaml" -n $(NAMESPACE)
kubectl apply -f "https://raw.githubusercontent.com/netobserv/documents/main/examples/kafka/metrics-config.yaml" -n $(NAMESPACE)
curl -s -L "https://raw.githubusercontent.com/netobserv/documents/main/examples/kafka/tls.yaml" | envsubst | kubectl apply -n $(NAMESPACE) -f -
kubectl apply -f "https://raw.githubusercontent.com/netobserv/documents/main/examples/kafka/topic.yaml" -n $(NAMESPACE)
kubectl apply -f "https://raw.githubusercontent.com/netobserv/documents/main/examples/kafka/user.yaml" -n $(NAMESPACE)
kubectl wait --timeout=180s --for=condition=ready kafkauser flp-kafka -n $(NAMESPACE)
.PHONY: undeploy-kafka
undeploy-kafka: ## Undeploy kafka.
@echo -e "\n==> Undeploy kafka"
kubectl delete -f "https://raw.githubusercontent.com/netobserv/documents/main/examples/kafka/topic.yaml" -n $(NAMESPACE) --ignore-not-found=true
kubectl delete kafkanodepool kafka-pool -n $(NAMESPACE) --ignore-not-found=true
kubectl delete kafkauser flp-kafka -n $(NAMESPACE) --ignore-not-found=true
kubectl delete kafka kafka-cluster -n $(NAMESPACE) --ignore-not-found=true
curl -s -L "https://raw.githubusercontent.com/netobserv/documents/main/examples/kafka/strimzi-cluster-operator.yaml" | sed -r 's/namespace: (default|myproject)/namespace: $(NAMESPACE)/g' | kubectl delete -n $(NAMESPACE) -f -
.PHONY: deploy-grafana
deploy-grafana: ## Deploy grafana.
@echo -e "\n==> Deploy grafana"
kubectl create namespace $(NAMESPACE) --dry-run=client -o yaml | kubectl apply -f -
kubectl config set-context --current --namespace=$(NAMESPACE)
./hack/deploy-grafana.sh $(NAMESPACE)
-pkill --oldest --full "3000:3000"
ifeq (true, $(PORT_FWD))
-kubectl port-forward --address 0.0.0.0 svc/grafana 3000:3000 2>&1 >/dev/null &
@echo -e "\n===> grafana ui is available (user: admin password: admin) on http://localhost:3000\n"
endif
.PHONY: undeploy-grafana
undeploy-grafana: ## Undeploy grafana.
@echo -e "\n==> Undeploy grafana"
kubectl config set-context --current --namespace=$(NAMESPACE)
kubectl delete --ignore-not-found=true deployment grafana
kubectl delete --ignore-not-found=true service grafana
kubectl delete --ignore-not-found=true configMap grafana-datasources
-pkill --oldest --full "3000:3000"
.PHONY: deploy-infra
deploy-infra: manifests generate fmt lint deploy-loki deploy-grafana install
.PHONY: deploy-all
deploy-all: deploy-infra deploy-sample-cr deploy-sample-workload
.PHONY: undeploy-infra
undeploy-infra: undeploy-loki undeploy-grafana uninstall
.PHONY: undeploy-all
undeploy-all: undeploy-infra undeploy-sample-cr undeploy-sample-workload
.PHONY: deploy-prometheus
deploy-prometheus: ## Deploy prometheus.
@echo -e "\n==> Deploy prometheus"
kubectl create namespace $(NAMESPACE) || true
kubectl config set-context --current --namespace=$(NAMESPACE)
kubectl apply -f config/kind/deployment-prometheus.yaml
kubectl rollout status "deploy/prometheus" --timeout=600s
-pkill --oldest --full "9090:9090"
ifeq (true, $(PORT_FWD))
kubectl port-forward --address 0.0.0.0 svc/prometheus 9090:9090 2>&1 >/dev/null &
@echo -e "\n===> prometheus ui is available on http://localhost:9090\n"
endif
.PHONY: undeploy-prometheus
undeploy-prometheus: ## Undeploy prometheus.
@echo -e "\n==> Undeploy prometheus"
kubectl --ignore-not-found=true delete -f config/kind/deployment-prometheus.yaml || true
-pkill --oldest --full "9090:9090"
.PHONY: get-related-images
get-related-images:
kubectl set env -n $(NAMESPACE) deployment netobserv-controller-manager -c "manager" --list
.PHONY: set-agent-image
set-agent-image:
ifeq ("", "$(CSV)")
kubectl set env -n $(NAMESPACE) deployment netobserv-controller-manager -c "manager" RELATED_IMAGE_EBPF_AGENT=$(IMAGE_REGISTRY)/$(USER)/netobserv-ebpf-agent:$(VERSION)
else
./hack/swap-image-csv.sh $(CSV) $(OPERATOR_NS) ebpf-agent RELATED_IMAGE_EBPF_AGENT $(IMAGE_REGISTRY)/$(USER)/netobserv-ebpf-agent:$(VERSION)
endif
@echo -e "\n==> Redeploying..."
kubectl rollout status -n $(OPERATOR_NS) --timeout=60s deployment netobserv-controller-manager
kubectl wait -n $(OPERATOR_NS) --timeout=60s --for condition=Available=True deployment netobserv-controller-manager
@echo -e "\n==> Wait a moment before agents are fully redeployed"
.PHONY: set-flp-image
set-flp-image:
ifeq ("", "$(CSV)")
kubectl set env -n $(NAMESPACE) deployment netobserv-controller-manager -c "manager" RELATED_IMAGE_FLOWLOGS_PIPELINE=$(IMAGE_REGISTRY)/$(USER)/flowlogs-pipeline:$(VERSION)
else
./hack/swap-image-csv.sh $(CSV) $(OPERATOR_NS) flowlogs-pipeline RELATED_IMAGE_FLOWLOGS_PIPELINE $(IMAGE_REGISTRY)/$(USER)/flowlogs-pipeline:$(VERSION)
endif
@echo -e "\n==> Redeploying..."
kubectl rollout status -n $(OPERATOR_NS) --timeout=60s deployment netobserv-controller-manager
kubectl wait -n $(OPERATOR_NS) --timeout=60s --for condition=Available=True deployment netobserv-controller-manager
@echo -e "\n==> Wait a moment before FLP is fully redeployed"
.PHONY: set-plugin-image
set-plugin-image:
ifeq ("", "$(CSV)")
kubectl set env -n $(NAMESPACE) deployment netobserv-controller-manager -c "manager" RELATED_IMAGE_CONSOLE_PLUGIN=$(IMAGE_REGISTRY)/$(USER)/network-observability-console-plugin:$(VERSION)
kubectl set image deployment/netobserv-plugin-static netobserv-plugin-static=$(IMAGE_REGISTRY)/$(USER)/network-observability-console-plugin:$(VERSION)
else
./hack/swap-image-csv.sh $(CSV) $(OPERATOR_NS) console-plugin RELATED_IMAGE_CONSOLE_PLUGIN $(IMAGE_REGISTRY)/$(USER)/network-observability-console-plugin:$(VERSION)
endif
@echo -e "\n==> Redeploying..."
kubectl rollout status -n $(OPERATOR_NS) --timeout=60s deployment netobserv-controller-manager
kubectl wait -n $(OPERATOR_NS) --timeout=60s --for condition=Available=True deployment netobserv-controller-manager
@echo -e "\n==> Wait a moment before plugin pod is fully redeployed"
.PHONY: set-release-kind-downstream
set-release-kind-downstream:
ifeq ("", "$(CSV)")
kubectl -n $(NAMESPACE) set env deployment netobserv-controller-manager -c "manager" DOWNSTREAM_DEPLOYMENT=true
else
./hack/swap-image-csv.sh $(CSV) $(OPERATOR_NS) "" DOWNSTREAM_DEPLOYMENT true
endif
@echo -e "\n==> Redeploying..."
kubectl rollout status -n $(OPERATOR_NS) --timeout=60s deployment netobserv-controller-manager
kubectl wait -n $(OPERATOR_NS) --timeout=60s --for condition=Available=True deployment netobserv-controller-manager
.PHONY: pprof
pprof:
@echo -e "\n==> Enabling pprof... Check https://github.com/netobserv/netobserv-operator/blob/main/DEVELOPMENT.md#profiling for help."
kubectl -n $(NAMESPACE) set env deployment netobserv-controller-manager -c "manager" PROFILING_BIND_ADDRESS=:6060
@echo -e "\n==> Redeploying..."
kubectl rollout status -n $(NAMESPACE) --timeout=60s deployment netobserv-controller-manager
kubectl wait -n $(NAMESPACE) --timeout=60s --for condition=Available=True deployment netobserv-controller-manager
sleep 2
$(MAKE) pprof-pf
.PHONY: pprof-pf
pprof-pf:
@echo -e "\n==> Port-forwarding..."
oc get pods
kubectl port-forward -n $(NAMESPACE) $(shell kubectl get pod -l app=netobserv-operator -n $(NAMESPACE) -o jsonpath="{.items[0].metadata.name}") 6060
.PHONY: use-test-console
use-test-console:
@echo -e "\n==> Enabling the test console..."
ifeq ("", "$(CSV)")
kubectl set env -n $(NAMESPACE) deployment netobserv-controller-manager -c "manager" RELATED_IMAGE_CONSOLE_PLUGIN=$(IMAGE_REGISTRY)/$(USER)/network-observability-standalone-frontend:$(VERSION)
else
./hack/swap-image-csv.sh $(CSV) $(OPERATOR_NS) console-plugin RELATED_IMAGE_CONSOLE_PLUGIN $(IMAGE_REGISTRY)/$(USER)/network-observability-standalone-frontend:$(VERSION)
endif
@echo -e "\n==> Waiting for operator redeployed..."
kubectl rollout status -n $(OPERATOR_NS) --timeout=60s deployment netobserv-controller-manager
kubectl wait -n $(OPERATOR_NS) --timeout=60s --for condition=Available=True deployment netobserv-controller-manager
oc patch flowcollector cluster --type='json' -p '[{"op": "add", "path": "/spec/consolePlugin/standalone", "value": true}]'
@echo -e "\n==> Waiting for console-plugin pod..."
kubectl delete -n $(NAMESPACE) deployment netobserv-plugin
while ! kubectl get deployment netobserv-plugin; do sleep 1; done
kubectl rollout status -n $(NAMESPACE) --timeout=60s deployment netobserv-plugin
kubectl wait -n $(NAMESPACE) --timeout=60s --for condition=Available=True deployment netobserv-plugin
-pkill --oldest --full "9001:9001"
kubectl port-forward -n $(NAMESPACE) svc/netobserv-plugin 9001:9001 2>&1 >/dev/null &
@echo -e "\n===> Test console available at http://localhost:9001\n"