Skip to content

Commit 2997464

Browse files
Fix lint errors. Add required links
Signed-off-by: Marina Shustova <marina.shustova@xored.com>
1 parent 617f05f commit 2997464

23 files changed

Lines changed: 661 additions & 3 deletions

examples/nsm_consul/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# NSM + Consul interdomain example over kind clusters
22

3-
This example show how can be used nsm over
4-
5-
![NSM interdomain Scheme](./NSM+Istio_Datapath.svg "NSM Basic floating interdomain Scheme")
3+
This example show how Consul can be used over nsm
64

75

86
## Requires

examples/nsm_consul/dns/README.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
## Setup DNS for two clusters
2+
3+
This example shows how to simply configure three k8s clusters to know each other.
4+
Can be skipped if clusters setupped with external DNS.
5+
6+
## Run
7+
8+
Expose dns service for first cluster
9+
```bash
10+
kubectl --kubeconfig=$KUBECONFIG1 expose service kube-dns -n kube-system --port=53 --target-port=53 --protocol=TCP --name=exposed-kube-dns --type=LoadBalancer
11+
```
12+
13+
Wait for assigning IP address (note: you should see IP address in logs. If you dont see repeat this):
14+
```bash
15+
kubectl --kubeconfig=$KUBECONFIG1 get services exposed-kube-dns -n kube-system -o go-template='{{index (index (index (index .status "loadBalancer") "ingress") 0) "ip"}}'
16+
ip1=$(kubectl --kubeconfig=$KUBECONFIG1 get services exposed-kube-dns -n kube-system -o go-template='{{index (index (index (index .status "loadBalancer") "ingress") 0) "ip"}}')
17+
if [[ $ip1 == *"no value"* ]]; then
18+
ip1=$(kubectl --kubeconfig=$KUBECONFIG1 get services exposed-kube-dns -n kube-system -o go-template='{{index (index (index (index .status "loadBalancer") "ingress") 0) "hostname"}}')
19+
ip1=$(dig +short $ip1 | head -1)
20+
fi
21+
echo Selected externalIP: $ip1 for cluster1
22+
```
23+
24+
Expose dns service for the second cluster:
25+
```bash
26+
kubectl --kubeconfig=$KUBECONFIG2 expose service kube-dns -n kube-system --port=53 --target-port=53 --protocol=TCP --name=exposed-kube-dns --type=LoadBalancer
27+
```
28+
29+
Wait for assigning IP address (note: you should see IP address in logs. If you dont see repeat this):
30+
```bash
31+
kubectl --kubeconfig=$KUBECONFIG2 get services exposed-kube-dns -n kube-system -o go-template='{{index (index (index (index .status "loadBalancer") "ingress") 0) "ip"}}'
32+
ip2=$(kubectl --kubeconfig=$KUBECONFIG2 get services exposed-kube-dns -n kube-system -o go-template='{{index (index (index (index .status "loadBalancer") "ingress") 0) "ip"}}')
33+
if [[ $ip2 == *"no value"* ]]; then
34+
ip2=$(kubectl --kubeconfig=$KUBECONFIG2 get services exposed-kube-dns -n kube-system -o go-template='{{index (index (index (index .status "loadBalancer") "ingress") 0) "hostname"}}')
35+
ip2=$(dig +short $ip2 | head -1)
36+
fi
37+
echo Selected externalIP: $ip2 for cluster2
38+
```
39+
40+
Add DNS forwarding from cluster1 to cluster2:
41+
```bash
42+
cat > configmap.yaml <<EOF
43+
apiVersion: v1
44+
kind: ConfigMap
45+
metadata:
46+
name: coredns
47+
namespace: kube-system
48+
data:
49+
Corefile: |
50+
.:53 {
51+
errors
52+
health {
53+
lameduck 5s
54+
}
55+
ready
56+
kubernetes cluster.local in-addr.arpa ip6.arpa {
57+
pods insecure
58+
fallthrough in-addr.arpa ip6.arpa
59+
ttl 30
60+
}
61+
k8s_external my.cluster1
62+
prometheus :9153
63+
forward . /etc/resolv.conf {
64+
max_concurrent 1000
65+
}
66+
loop
67+
reload 5s
68+
}
69+
my.cluster2:53 {
70+
forward . ${ip2}:53 {
71+
force_tcp
72+
}
73+
}
74+
EOF
75+
kubectl --kubeconfig=$KUBECONFIG1 apply -f configmap.yaml
76+
cat > custom-configmap.yaml <<EOF
77+
apiVersion: v1
78+
kind: ConfigMap
79+
metadata:
80+
name: coredns-custom
81+
namespace: kube-system
82+
data:
83+
server.override: |
84+
k8s_external my.cluster2
85+
proxy1.server: |
86+
my.cluster2:53 {
87+
forward . ${ip2}:53 {
88+
force_tcp
89+
}
90+
}
91+
EOF
92+
93+
kubectl --kubeconfig=$KUBECONFIG1 apply -f custom-configmap.yaml
94+
```
95+
96+
Add DNS forwarding from cluster2 to cluster1:
97+
```bash
98+
cat > configmap.yaml <<EOF
99+
apiVersion: v1
100+
kind: ConfigMap
101+
metadata:
102+
name: coredns
103+
namespace: kube-system
104+
data:
105+
Corefile: |
106+
.:53 {
107+
errors
108+
health {
109+
lameduck 5s
110+
}
111+
ready
112+
kubernetes cluster.local in-addr.arpa ip6.arpa {
113+
pods insecure
114+
fallthrough in-addr.arpa ip6.arpa
115+
ttl 30
116+
}
117+
k8s_external my.cluster2
118+
prometheus :9153
119+
forward . /etc/resolv.conf {
120+
max_concurrent 1000
121+
}
122+
loop
123+
reload 5s
124+
}
125+
my.cluster1:53 {
126+
forward . ${ip1}:53 {
127+
force_tcp
128+
}
129+
}
130+
EOF
131+
kubectl --kubeconfig=$KUBECONFIG2 apply -f configmap.yaml
132+
cat > custom-configmap.yaml <<EOF
133+
apiVersion: v1
134+
kind: ConfigMap
135+
metadata:
136+
name: coredns-custom
137+
namespace: kube-system
138+
data:
139+
server.override: |
140+
k8s_external my.cluster1
141+
proxy1.server: |
142+
my.cluster1:53 {
143+
forward . ${ip1}:53 {
144+
force_tcp
145+
}
146+
}
147+
EOF
148+
kubectl --kubeconfig=$KUBECONFIG2 apply -f custom-configmap.yaml
149+
```
150+
151+
## Cleanup
152+
153+
```bash
154+
kubectl --kubeconfig=$KUBECONFIG1 delete service -n kube-system exposed-kube-dns
155+
kubectl --kubeconfig=$KUBECONFIG2 delete service -n kube-system exposed-kube-dns
156+
```
157+
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Kubernetes load balancer
2+
3+
Before starting with installation, make sure you meet all the [requirements](https://metallb.universe.tf/#requirements). In particular, you should pay attention to network addon [compatibility](https://metallb.universe.tf/installation/clouds/).
4+
5+
If you’re trying to run MetalLB on a cloud platform, you should also look at the cloud compatibility page and make sure your cloud platform can work with MetalLB (most cannot).
6+
7+
There are three supported ways to install MetalLB: using plain Kubernetes manifests, using Kustomize, or using Helm.
8+
9+
## Run
10+
11+
Apply metallb for the first cluster:
12+
```bash
13+
if [[ ! -z $CLUSTER1_CIDR ]]; then
14+
kubectl --kubeconfig=$KUBECONFIG1 apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/namespace.yaml
15+
kubectl --kubeconfig=$KUBECONFIG1 apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/metallb.yaml
16+
cat > metallb-config.yaml <<EOF
17+
apiVersion: v1
18+
kind: ConfigMap
19+
metadata:
20+
namespace: metallb-system
21+
name: config
22+
data:
23+
config: |
24+
address-pools:
25+
- name: default
26+
protocol: layer2
27+
addresses:
28+
- $CLUSTER1_CIDR
29+
EOF
30+
kubectl --kubeconfig=$KUBECONFIG1 apply -f metallb-config.yaml
31+
kubectl --kubeconfig=$KUBECONFIG1 wait --for=condition=ready --timeout=5m pod -l app=metallb -n metallb-system
32+
fi
33+
```
34+
35+
Apply metallb for the second cluster:
36+
```bash
37+
if [[ ! -z $CLUSTER2_CIDR ]]; then
38+
kubectl --kubeconfig=$KUBECONFIG2 apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/namespace.yaml
39+
kubectl --kubeconfig=$KUBECONFIG2 apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/metallb.yaml
40+
cat > metallb-config.yaml <<EOF
41+
apiVersion: v1
42+
kind: ConfigMap
43+
metadata:
44+
namespace: metallb-system
45+
name: config
46+
data:
47+
config: |
48+
address-pools:
49+
- name: default
50+
protocol: layer2
51+
addresses:
52+
- $CLUSTER2_CIDR
53+
EOF
54+
kubectl --kubeconfig=$KUBECONFIG2 apply -f metallb-config.yaml
55+
kubectl --kubeconfig=$KUBECONFIG2 wait --for=condition=ready --timeout=5m pod -l app=metallb -n metallb-system
56+
fi
57+
```
58+
59+
## Cleanup
60+
61+
Delete metallb-system namespace from all clusters:
62+
63+
```bash
64+
if [[ ! -z $CLUSTER1_CIDR ]]; then
65+
kubectl --kubeconfig=$KUBECONFIG2 delete ns metallb-system
66+
fi
67+
```
68+
69+
```bash
70+
if [[ ! -z $CLUSTER2_CIDR ]]; then
71+
kubectl --kubeconfig=$KUBECONFIG1 delete ns metallb-system
72+
fi
73+
```

examples/nsm_consul/nsm/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# NSM interdomain setup
2+
3+
4+
This example simply show how can be deployed and configured two NSM on different clusters
5+
6+
## Run
7+
8+
Install NSM
9+
```bash
10+
kubectl --kubeconfig=$KUBECONFIG1 apply -k ./cluster1
11+
kubectl --kubeconfig=$KUBECONFIG2 apply -k ./cluster2
12+
```
13+
14+
## Cleanup
15+
16+
Cleanup NSM
17+
```bash
18+
WH=$(kubectl --kubeconfig=$KUBECONFIG1 get pods -l app=admission-webhook-k8s -n nsm-system --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
19+
kubectl --kubeconfig=$KUBECONFIG1 delete mutatingwebhookconfiguration ${WH}
20+
21+
WH=$(kubectl --kubeconfig=$KUBECONFIG2 get pods -l app=admission-webhook-k8s -n nsm-system --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
22+
kubectl --kubeconfig=$KUBECONFIG2 delete mutatingwebhookconfiguration ${WH}
23+
24+
kubectl --kubeconfig=$KUBECONFIG1 delete -k ./cluster1
25+
kubectl --kubeconfig=$KUBECONFIG2 delete -k ./cluster2
26+
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
5+
namespace: nsm-system
6+
7+
bases:
8+
- https://github.com/networkservicemesh/deployments-k8s/apps/nsmgr?ref=b4bddacfa45fafb7c15a769a1fc0f319e63d6a8d
9+
- https://github.com/networkservicemesh/deployments-k8s/apps/forwarder-vpp?ref=b4bddacfa45fafb7c15a769a1fc0f319e63d6a8d
10+
- https://github.com/networkservicemesh/deployments-k8s/apps/registry-k8s?ref=b4bddacfa45fafb7c15a769a1fc0f319e63d6a8d
11+
- https://github.com/networkservicemesh/deployments-k8s/apps/registry-proxy-dns?ref=b4bddacfa45fafb7c15a769a1fc0f319e63d6a8d
12+
- https://github.com/networkservicemesh/deployments-k8s/apps/nsmgr-proxy?ref=b4bddacfa45fafb7c15a769a1fc0f319e63d6a8d
13+
- https://github.com/networkservicemesh/deployments-k8s/apps/admission-webhook-k8s?ref=b4bddacfa45fafb7c15a769a1fc0f319e63d6a8d
14+
15+
resources:
16+
- namespace.yaml
17+
18+
patchesStrategicMerge:
19+
- patch-nsmgr-proxy.yaml
20+
- patch-registry-proxy-dns.yaml
21+
- patch-registry.yaml
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
apiVersion: v1
3+
kind: Namespace
4+
metadata:
5+
name: nsm-system
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: nsmgr-proxy
6+
spec:
7+
template:
8+
metadata:
9+
annotations:
10+
spiffe.io/federatesWith: nsm.cluster2
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: registry-proxy
6+
spec:
7+
template:
8+
metadata:
9+
annotations:
10+
spiffe.io/federatesWith: nsm.cluster2
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: registry-k8s
6+
spec:
7+
template:
8+
metadata:
9+
annotations:
10+
spiffe.io/federatesWith: nsm.cluster2
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
5+
namespace: nsm-system
6+
7+
bases:
8+
- https://github.com/networkservicemesh/deployments-k8s/apps/nsmgr?ref=b4bddacfa45fafb7c15a769a1fc0f319e63d6a8d
9+
- https://github.com/networkservicemesh/deployments-k8s/apps/forwarder-vpp?ref=b4bddacfa45fafb7c15a769a1fc0f319e63d6a8d
10+
- https://github.com/networkservicemesh/deployments-k8s/apps/registry-k8s?ref=b4bddacfa45fafb7c15a769a1fc0f319e63d6a8d
11+
- https://github.com/networkservicemesh/deployments-k8s/apps/registry-proxy-dns?ref=b4bddacfa45fafb7c15a769a1fc0f319e63d6a8d
12+
- https://github.com/networkservicemesh/deployments-k8s/apps/nsmgr-proxy?ref=b4bddacfa45fafb7c15a769a1fc0f319e63d6a8d
13+
- https://github.com/networkservicemesh/deployments-k8s/apps/admission-webhook-k8s?ref=b4bddacfa45fafb7c15a769a1fc0f319e63d6a8d
14+
15+
patchesStrategicMerge:
16+
- patch-nsmgr-proxy.yaml
17+
- patch-registry-proxy-dns.yaml
18+
- patch-registry.yaml
19+
20+
resources:
21+
- namespace.yaml

0 commit comments

Comments
 (0)