-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
50 lines (38 loc) · 1.52 KB
/
Makefile
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
NS=test
KUBECTL=kubectl -n $(NS)
export GREP=grep --color=never
OPERATOR=example/deployment-operator.yaml
MASTER=$$( for POD in $$( $(KUBECTL) get po | $(GREP) fencing-operator.*Running | awk '{print $$1}' ); do $(KUBECTL) logs po/$$POD ; done | sort | /bin/grep "became leader" | sed s/.*LeaderElection\'// | awk '{print $$1}')
all: build
build:
operator-sdk build quay.io/beekhof/fencing-operator
push: build
docker push quay.io/beekhof/fencing-operator
generated:
operator-sdk generate k8s
ns:
-kubectl create ns $(NS)
-example/rbac/create_role.sh --namespace $(NS) --role-name $(NS)-operator --role-binding-name $(NS)-operator
run: clean ns
$(KUBECTL) create -f example/config.yaml
$(KUBECTL) create -f $(OPERATOR)
echo -n "Waiting..."
while [ "x$$( $(KUBECTL) get po | grep fencing-operator-.*Running)" = x ]; do sleep 5; /bin/echo -n .; done
sleep 5 # Give time for one of the pods to become the leader
echo " done"
logs:
$(KUBECTL) describe pods | grep -e ^Name: -e ^Node: | sed 's/Node:/ /'
echo $(KUBECTL) logs -f $(MASTER)
$(KUBECTL) logs -f $(MASTER)
clean: clean-op clean-ns
clean-op:
-$(KUBECTL) delete -f $(OPERATOR)
-$(KUBECTL) delete -f example/config.yaml
echo -n "Waiting..."
while [ "x$$($(KUBECTL) get po 2>/dev/null)" != "x" ]; do sleep 5; /bin/echo -n .; done
echo " done"
clean-ns:
-kubectl delete ns/$(NS) clusterrole/$(NS)-operator clusterrolebinding/$(NS)-operator
echo -n "Waiting..."
while [ "x$$(kubectl get ns $(NS) 2>/dev/null)" != "x" ]; do sleep 5; /bin/echo -n .; done
echo " done"