Skip to content

Commit 396ca73

Browse files
author
orannahoum
committed
Fix service issue on kins installation
Add instructions on how to run on kind
1 parent f3a000f commit 396ca73

11 files changed

+215
-26
lines changed

.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+24-4
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,41 @@ To set up this operator follow the instructions below:
1616
darwin/amd64
1717

1818
* An openshift cluster
19+
* If you wish to run this locally by using kind please check [KindInstallationREADME.md](hack/KindInstallationREADME.md)
20+
1921

2022

2123
### Modyfing the CRD
2224
Modify the file config/skydive_v1_skydivesuite.yaml and pick what you wish to deploy (insert true or false in the relevant field), the options are as follows:
2325
* Skydive agents
2426
* Skydive analyzer
25-
* Service route - TODO: doesn't work on IBM cluster.
27+
* Service route
28+
* Flow exporter
2629

2730
Choose your logging level (defaults to INFO)
2831

2932

3033
### Installation - Open-Shift
3134

3235
run the zsh script :
33-
```deploy_operator_on_openshift.sh```
36+
```sh
37+
deploy_operator_on_openshift.sh
38+
```
39+
40+
#### Analyzer UI
41+
1a. Check that all the pods, services and routes are running and afterwards run the following command:
42+
43+
```sh
44+
oc get routes
45+
```
46+
47+
2a. post the url into your web-browser
48+
49+
1b. If routes option doesn't work, run the following command
50+
```sh
51+
oc port-forward service/skydive-analyzer 8082:8082 --namespace=skydive
52+
```
53+
54+
2b. Now open web-browser on localhost:8082
55+
3456

35-
### Installation - Kubernetes
36-
*** to be continued

api/v1/skydivesuite_types.go

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ type EnableSpec struct {
4444
// +optional
4545
// +kubebuilder:default=false
4646
Route bool `json:"route,omitempty"`
47+
48+
// +optional
49+
// +kubebuilder:default=true
50+
FlowExporter bool `json:"flowExporter,omitempty"`
4751
}
4852

4953
type LoggingSpec struct {

assets/flow-exporter/deployment.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Skydive FlowExporter (Deployment)
2+
#
3+
# Containers included in this pod::
4+
# (1) Skydive Flow Exporter - Flow exporter (connects to Skydive Analyzer)
5+
apiVersion: apps/v1
6+
kind: Deployment
7+
metadata:
8+
name: skydive-flow-exporter
9+
spec:
10+
replicas: 1
11+
selector:
12+
matchLabels:
13+
app: skydive-flow-exporter
14+
tier: flow-exporter
15+
template:
16+
metadata:
17+
labels:
18+
app: skydive-flow-exporter
19+
tier: flow-exporter
20+
spec:
21+
containers:
22+
- image: skydive/skydive-flow-exporter
23+
imagePullPolicy: Always
24+
name: skydive-flow-exporter
25+
env:
26+
- name: SKYDIVE_LOGGING_LEVEL
27+
value: ${SKYDIVE_LOGGING_LEVEL}
28+
- name: SKYDIVE_PIPELINE_SUBSCRIBER_URL
29+
value: ws://skydive-analyzer:8082/ws/subscriber/flow

assets/skydive-analyzer/service.yaml

+12-13
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,32 @@
22
apiVersion: v1
33
kind: Service
44
metadata:
5+
name: skydive-analyzer
56
labels:
67
app: skydive-analyzer
7-
name: skydive-analyzer
88
spec:
9+
type: ClusterIP
910
ports:
10-
- name: api
11-
port: 8082
11+
- port: 8082
12+
name: api
1213
protocol: TCP
1314
targetPort: 8082
14-
- name: protobuf
15-
port: 8082
15+
- port: 8082
16+
name: protobuf
1617
protocol: UDP
1718
targetPort: 8082
18-
- name: etcd
19-
port: 12379
19+
- port: 12379
20+
name: etcd
2021
protocol: TCP
2122
targetPort: 12379
22-
- name: etcd-cluster
23-
port: 12380
23+
- port: 12380
24+
name: etcd-cluster
2425
protocol: TCP
2526
targetPort: 12380
26-
- name: es
27-
port: 9200
27+
- port: 9200
28+
name: es
2829
protocol: TCP
2930
targetPort: 9200
3031
selector:
3132
app: skydive
3233
tier: analyzer
33-
sessionAffinity: None
34-
type: NodePort

config/crd/bases/skydive.example.com_skydivesuites.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ spec:
4444
analyzer:
4545
default: true
4646
type: boolean
47+
flowExporter:
48+
default: true
49+
type: boolean
4750
route:
4851
default: false
4952
type: boolean

config/skydive_v1_skydivesuite.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ spec:
77
enable:
88
analyzer: true
99
agents: true
10-
route: true
10+
route: false
11+
flowExporter: false
1112
logging:
1213
level: "INFO"

controllers/skydivesuite_controller.go

+36-7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var (
3535
SkydiveAnalyzerDeployment = "skydive-analyzer/deployment.yaml"
3636
SkydiveAnalyzerRoute = "skydive-analyzer/route.yaml"
3737
SkydiveAnalyzerService = "skydive-analyzer/service.yaml"
38+
SkydiveFlowExporter = "flow-exporter/deployment.yaml"
3839
)
3940

4041
// SkydiveSuiteReconciler reconciles a SkydiveSuite object
@@ -82,7 +83,7 @@ func (r *SkydiveSuiteReconciler) Reconcile(ctx context.Context, req ctrl.Request
8283

8384
err = kclient_instance.CreateOrUpdateDeployment(dep)
8485
if err != nil {
85-
return ctrl.Result{}, errors.Wrap(err, "Deployment creation has failed")
86+
return ctrl.Result{}, errors.Wrap(err, "Skydive analyzer deployment creation has failed")
8687
}
8788

8889
svc, err := kclient.NewService(assets.MustNewAssetReader(SkydiveAnalyzerService))
@@ -99,35 +100,63 @@ func (r *SkydiveSuiteReconciler) Reconcile(ctx context.Context, req ctrl.Request
99100
if skydive_suite.Spec.Enable.Route {
100101
route, err := kclient.NewRoute(assets.MustNewAssetReader(SkydiveAnalyzerRoute))
101102
if err != nil {
102-
return ctrl.Result{}, errors.Wrap(err, "initializing skydive-analyzer Route failed")
103+
log.Error(err, "initializing skydive-analyzer Route failed")
103104
}
104105
route.Namespace = skydive_suite.Spec.Namespace
105106

106107
err = kclient_instance.CreateRouteIfNotExists(route)
107108
if err != nil {
108-
return ctrl.Result{}, errors.Wrap(err, "Route creation has failed")
109+
log.Error(err, "Route creation has failed")
109110
}
110111

111112
_, err = kclient_instance.WaitForRouteReady(route)
112113
if err != nil {
113-
return ctrl.Result{}, errors.Wrap(err, "waiting for Skydive Route to become ready failed")
114+
log.Error(err, "waiting for Skydive Route to become ready failed")
114115
}
115116
}
116117

117118
}
118119

119120
// Creating skydive Agents
120121
if skydive_suite.Spec.Enable.Agents {
121-
122122
ds, err := kclient.NewDaemonSet(assets.MustNewAssetReader(SkydiveAgentsDaemonSet))
123123
if err != nil {
124124
return ctrl.Result{}, errors.Wrap(err, "initializing skydive-agents DaemonSet failed")
125125
}
126126
ds.Namespace = skydive_suite.Spec.Namespace
127-
127+
for _, container := range ds.Spec.Template.Spec.Containers {
128+
for _, env := range container.Env {
129+
switch env.Name {
130+
case "SKYDIVE_LOGGING_LEVEL":
131+
env.Value = skydive_suite.Spec.Logging.Level
132+
}
133+
}
134+
}
128135
err = kclient_instance.CreateOrUpdateDaemonSet(ds)
129136
if err != nil {
130-
return ctrl.Result{}, errors.Wrap(err, "UI-Route creation has failed")
137+
return ctrl.Result{}, errors.Wrap(err, "DaemonSet creation failed")
138+
}
139+
}
140+
141+
if skydive_suite.Spec.Enable.FlowExporter {
142+
dep, err := kclient.NewDeployment(assets.MustNewAssetReader(SkydiveFlowExporter))
143+
if err != nil {
144+
log.Error(err, "initializing skydive flow-exporter Deployment failed")
145+
return ctrl.Result{}, errors.Wrap(err, "initializing skydive flow-exporter Deployment failed")
146+
}
147+
dep.Namespace = skydive_suite.Spec.Namespace
148+
for _, container := range dep.Spec.Template.Spec.Containers {
149+
for _, env := range container.Env {
150+
switch env.Name {
151+
case "SKYDIVE_LOGGING_LEVEL":
152+
env.Value = skydive_suite.Spec.Logging.Level
153+
}
154+
}
155+
}
156+
157+
err = kclient_instance.CreateOrUpdateDeployment(dep)
158+
if err != nil {
159+
return ctrl.Result{}, errors.Wrap(err, "Flow exporter deployment creation has failed")
131160
}
132161
}
133162

deploy_operator_on_openshift.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ oc_set_credentials() {
2525
oc adm policy add-cluster-role-to-user cluster-reader -z default
2626
}
2727

28+
oc_clear_skydivesuite_crd() {
29+
SKYDIVE_SUITE_CRD=$(oc get skydivesuite)
30+
if [ ! -z "$SKYDIVE_SUITE_CRD" ]; then
31+
oc delete -f config/crd/bases
32+
fi
33+
}
34+
2835
# deoploy skydive
2936
oc_deploy_skydive() {
3037
make manifests
@@ -35,10 +42,11 @@ oc_deploy_skydive() {
3542

3643
# main
3744
main() {
38-
echo "starting"
3945
oc_delete_skydive_project_if_exists
4046
oc_create_skydive_project
4147
oc_set_credentials
48+
oc_clear_skydivesuite_crd
4249
oc_deploy_skydive
4350
}
51+
4452
main

hack/KindInstallationREADME.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!-- ABOUT THE PROJECT -->
2+
3+
# Running Skydive Operator on Kind cluster
4+
5+
This is a simple deployment guide for the operator on a kind cluster
6+
7+
<!-- GETTING STARTED -->
8+
9+
## Getting Started
10+
11+
To set up this operator on a kind follow the instructions below:
12+
13+
### Prerequisites
14+
15+
* Make sure you have golang installed on your machine, The go-lang version that this operator was built on is go1.15.7
16+
darwin/amd64
17+
18+
* Kind installed
19+
20+
### Modyfing the CRD
21+
Modify the file config/skydive_v1_skydivesuite.yaml and pick what you wish to deploy (insert true or false in the relevant field), the options are as follows:
22+
* Skydive agents
23+
* Skydive analyzer
24+
* Service route
25+
* Flow exporter
26+
27+
Choose your logging level (defaults to INFO)
28+
29+
### Installation
30+
31+
#### Kind
32+
Install kind on your machine, use [this](https://kind.sigs.k8s.io/docs/user/quick-start/) quick start guide for help,
33+
make sure that your have a running kind cluster and that kubectl commands refer to relevant context.
34+
35+
run the zsh script :
36+
```deploy_operator_on_kind.sh```
37+
38+
#### Analyzer UI
39+
1. Check that all the pods and services are running and afterwards run the following command:
40+
41+
```sh
42+
kubectl port-forward service/skydive-analyzer 8082:8082 --namespace=skydive
43+
```
44+
45+
2. Now open browser on localhost:8082

hack/deploy_operator_on_kind.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# delete skydive project if it exists (to get new frech deployment)
2+
kubectl_delete_skydive_project_if_exists() {
3+
NAMESPACE_SKYDIVE=$(kubectl get namespace | grep skydive)
4+
if [ ! -z "$NAMESPACE_SKYDIVE" ]; then
5+
kubectl delete namespace skydive
6+
while : ; do
7+
NAMESPACE_SKYDIVE=$(kubectl get project | grep skydive)
8+
if [ -z "$PROJECT_SKYDIVE" ]; then break; fi
9+
sleep 1
10+
done
11+
fi
12+
}
13+
14+
# create and switch context to skydive project
15+
kubectl_create_skydive_project() {
16+
kubectl create namespace skydive
17+
}
18+
19+
kubectl_clear_skydivesuite_crd() {
20+
SKYDIVE_SUITE_CRD=$(kubectl get skydivesuite)
21+
if [ ! -z "$SKYDIVE_SUITE_CRD" ]; then
22+
kubectl delete -f ../config/crd/bases
23+
fi
24+
}
25+
26+
# deoploy skydive
27+
kubectl_deploy_skydive() {
28+
cd ..
29+
make manifests
30+
kubectl create -f config/crd/bases
31+
kubectl create -f config/skydive_v1_skydivesuite.yaml
32+
make run
33+
}
34+
35+
# main
36+
main() {
37+
kubectl_delete_skydive_project_if_exists
38+
kubectl_create_skydive_project
39+
kubectl_clear_skydivesuite_crd
40+
kubectl_deploy_skydive
41+
}
42+
43+
main

0 commit comments

Comments
 (0)