Skip to content

Commit fd4c3f5

Browse files
committed
Working manifest
1 parent 876a9b7 commit fd4c3f5

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

Dockerfile

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ ENV CGO_ENABLED 0
44
ENV GOOS linux
55
WORKDIR /
66
COPY . .
7-
RUN go get -d && go mod download && go build -a -ldflags "-s -w" -installsuffix cgo -o beaveragentagent .
7+
ENV GOPROXY=http://registry.ik8s.ir/repository/golang.org/
8+
RUN go get -d && go mod download && go build -a -ldflags "-s -w" -installsuffix cgo -o beaveragent .
89

910
FROM registry.ik8s.ir/alpine:latest
1011
COPY --from=builder /beaveragent .
11-
COPY --from=builder /cmd.sh .
12-
RUN apk --no-cache add ca-certificates openvswitch && mkdir -p /host/var/run/openvswitch && mkdir -p /host/var/lib/openvswitch && chmod +x ./beaveragent && chmod +x ./cmd.sh
12+
COPY --from=builder /entrypoint.sh .
13+
RUN apk --no-cache add ca-certificates openvswitch && mkdir -p /host/var/run/openvswitch && mkdir -p /host/var/lib/openvswitch && chmod +x ./beaveragent && chmod +x ./entrypoint.sh
1314
WORKDIR /
1415

15-
CMD ["./cmd.sh && ./beaveragent"]
16+
CMD ["./entrypoint.sh"]

cmd.sh entrypoint.sh

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
#!/bin/sh
2-
2+
# create ovs database if not exist.
33
ovsdb-tool create /host/var/lib/openvswitch/conf.db 2> /dev/null
4+
# run ovsdb server
45
ovsdb-server \
56
--unixctl=/host/var/run/openvswitch/ovsdb-server.0.ctl \
67
--pidfile=/host/var/run/openvswitch/ovsdb-server.pid \
78
--remote=punix:/host/var/run/openvswitch/db.sock \
89
--overwrite-pidfile \
910
--detach \
1011
/host/var/lib/openvswitch/conf.db
11-
12+
#run openvswitch daemon
1213
ovs-vswitchd \
1314
--unixctl=/host/var/run/openvswitch/ovs-vswitchd.0.ctl \
1415
--pidfile=/host/var/run/openvswitch/ovs-vswitchd.pid \
1516
--overwrite-pidfile \
1617
--detach \
1718
unix:/host/var/run/openvswitch/db.sock
18-
1919
# create default public external internet bridge
20-
ovs-vsctl --db=unix:/host/var/run/openvswitch/db.sock add-br $OVS_BRIDGE 2> /dev/null
21-
ovs-vsctl --db=unix:/host/var/run/openvswitch/db.sock add-port $OVS_BRIDGE $NODE_NIC 2> /dev/null
20+
ovs-vsctl --db=unix:/host/var/run/openvswitch/db.sock add-br $DEFAULT_OVS_BRIDGE 2> /dev/null
21+
ovs-vsctl --db=unix:/host/var/run/openvswitch/db.sock add-port $DEFAULT_OVS_BRIDGE $NODE_NIC 2> /dev/null
2222

2323
# Isolataion for default public external network
24-
ovs-ofctl --db=unix:/host/var/run/openvswitch/db.sock del-flows $OVS_BRIDGE
25-
ovs-ofctl --db=unix:/host/var/run/openvswitch/db.sock add-flow $OVS_BRIDGE "priority=0,actions=drop"
26-
ovs-ofctl --db=unix:/host/var/run/openvswitch/db.sock add-flow $OVS_BRIDGE "in_port=$NODE_NIC,actions=NORMAL"
27-
ovs-ofctl --db=unix:/host/var/run/openvswitch/db.sock add-flow $OVS_BRIDGE "actions=output=$NODE_NIC"
24+
ovs-ofctl --db=unix:/host/var/run/openvswitch/db.sock del-flows $DEFAULT_OVS_BRIDGE
25+
ovs-ofctl --db=unix:/host/var/run/openvswitch/db.sock add-flow $DEFAULT_OVS_BRIDGE "priority=0,actions=drop"
26+
ovs-ofctl --db=unix:/host/var/run/openvswitch/db.sock add-flow $DEFAULT_OVS_BRIDGE "in_port=$NODE_NIC,actions=NORMAL"
27+
ovs-ofctl --db=unix:/host/var/run/openvswitch/db.sock add-flow $DEFAULT_OVS_BRIDGE "actions=output=$NODE_NIC"
28+
29+
# run the agent
30+
./beaveragent

manifests/beaveragent.yaml

+11-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ spec:
1717
imagePullPolicy: Always
1818
name: beaveragent
1919
resources: {}
20+
env:
21+
- name: DEFAULT_OVS_BRIDGE
22+
value: ext
23+
- name: NODE_NIC
24+
value: eno33559296
2025
securityContext:
2126
capabilities:
2227
add:
@@ -31,6 +36,9 @@ spec:
3136
name: nodeovslib
3237
- mountPath: /lib/modules
3338
name: kernel-modules
39+
hostIPC: true
40+
hostNetwork: true
41+
hostPID: true
3442
tolerations:
3543
- effect: NoSchedule
3644
key: node-role.kubernetes.io/master
@@ -56,10 +64,11 @@ apiVersion: v1
5664
kind: Service
5765
metadata:
5866
name: beaveragent-headless
67+
namespace: ik8s-system
5968
spec:
6069
selector:
6170
app: beaveragent
6271
clusterIP: None
6372
ports:
64-
port: 8000
65-
targetPort: 8000
73+
- port: 8000
74+
targetPort: 8000

0 commit comments

Comments
 (0)