How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019 · •K8s services reachable...
Transcript of How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019 · •K8s services reachable...
Copyright © Ciena Corporation 2019. All rights reserved.
Kent Hagerman
How I Stuffed my Laptop inside a K8s Pod
2Copyright © Ciena Corporation 2019. All rights reserved.
K8s App Development is a Frustrating Process
1. Build container 2. Push container3. Redeploy4. Test / Experiment5. Recover logs6. Optionally goto 4.7. Make changes8. Repeat k8s cluster
Node
Pod(WIP / indev)
Pod
Pod Pod
NodeNodeNode
Pod
Pod
17
32
54
4
4
3Copyright © Ciena Corporation 2019. All rights reserved.
k8s cluster
Wouldn’t this be so much better?
Node
Pod Pod
Pod Pod
NodeNodeNode
Pod Pod
Pod Pod
• K8s services reachable• Build-run-test directly
on laptop• Entire kubernetes
environment available• Allow outbound &
inbound connections to & from other pods
4Copyright © Ciena Corporation 2019. All rights reserved.
k8s cluster
What I Have
• Remote access• Slow build-push-
redeploy-test cycle
ssh / kubectl Node
Pod(WIP / indev)
Pod
Pod Pod
NodeNodeNode
Pod Pod
Pod Pod
5Copyright © Ciena Corporation 2019. All rights reserved.
k8s cluster
• Forward pod’s open ports to local ports
• Proxy k8s-destined traffic through the pod
Something like this…
Node
Proxy Pod Pod
Pod Pod
NodeNodeNode
Pod Pod
Pod Pod
6Copyright © Ciena Corporation 2019. All rights reserved.
Design Goals
Ease of use• Replace in-dev application image with proxy image
• Deploy “as usual”
• Single command to connect laptop to proxy pod • Build-run-test apps on local machine
• Zero reconfiguration in the k8s cluster• Can build-run-test directly in IDE
7Copyright © Ciena Corporation 2019. All rights reserved.
• Pods
• Services
Switching gears…
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-ui
8Copyright © Ciena Corporation 2019. All rights reserved.
• Pods
• Services
K8s Environment
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-ui
9Copyright © Ciena Corporation 2019. All rights reserved.
Laptop -- Proxy Pod
proxy pod
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-ui
10Copyright © Ciena Corporation 2019. All rights reserved.
Outgoing Traffic
• Proxy traffic destined for k8s services through the pod
• Split DNS; proxy only *.cluster.local DNS requests through the pod
Proxy Pod
11Copyright © Ciena Corporation 2019. All rights reserved.
Demo #1Laptop -> K8s Service
12Copyright © Ciena Corporation 2019. All rights reserved.
13Copyright © Ciena Corporation 2019. All rights reserved.
Demo #1Laptop -> K8s Service
14Copyright © Ciena Corporation 2019. All rights reserved.
What Happened?
proxy pod
$ ./connect.sh
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-ui
15Copyright © Ciena Corporation 2019. All rights reserved.
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-uiWhat Happened?
proxy pod
$ ssh -p 5022 \[email protected]
(voltha) devices
16Copyright © Ciena Corporation 2019. All rights reserved.
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-uiWhat Happened?
proxy pod
$ voltctl device list
17Copyright © Ciena Corporation 2019. All rights reserved.
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-uiWhat Happened?
proxy pod
http://onos-ui.default.svc.cluster.local:8181/onos/ui
18Copyright © Ciena Corporation 2019. All rights reserved.
Laptop -> K8s
proxy pod
$ ./connect.sh
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-ui
19Copyright © Ciena Corporation 2019. All rights reserved.
Incoming Traffic
• Forward incoming traffic from the proxy pod to the laptop
• Redirect some k8s applications or services to the proxy pod
Proxy Pod
20Copyright © Ciena Corporation 2019. All rights reserved.
Demo #2K8s Service -> Laptop
21Copyright © Ciena Corporation 2019. All rights reserved.
22Copyright © Ciena Corporation 2019. All rights reserved.
Demo #2K8s Service -> Laptop
23Copyright © Ciena Corporation 2019. All rights reserved.
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-uiWhat happened?
proxy pod
Run application in IDE
affinity router
24Copyright © Ciena Corporation 2019. All rights reserved.
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-uiWhat happened?
proxy pod
$ ./redirect.sh \–namespace=voltha voltha-api
affinity router
25Copyright © Ciena Corporation 2019. All rights reserved.
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-uiWhat happened?
proxy pod
affinity router
(voltha) devices$ ssh -p 5022 \[email protected]
26Copyright © Ciena Corporation 2019. All rights reserved.
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-uiWhat happened?
proxy pod
$ voltctl device list
affinity router
27Copyright © Ciena Corporation 2019. All rights reserved.
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-uiK8s -> Laptop -> K8s
proxy pod
affinity router
28Copyright © Ciena Corporation 2019. All rights reserved.
voltha-api-server(affinity router)
voltha-api
Voltha-ro-core voltha-rw-core-11 voltha-rw-core-12
ofagentvoltha-cli-server
voltha-clionos
onos-uiK8s -> Laptop -> K8s
29Copyright © Ciena Corporation 2019. All rights reserved.
Final Thoughts
• Set up your environment just so.
• Don’t be afraid to reconsider bad processes.
• Make (better) tools.
30Copyright © Ciena Corporation 2019. All rights reserved.
Questions?
Tool repo: github.com/kent-h/k8s-become-pod