How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable...

30
Copyright © Ciena Corporation 2019. All rights reserved. Kent Hagerman How I Stuffed my Laptop inside a K8s Pod

Transcript of How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable...

Page 1: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

Copyright © Ciena Corporation 2019. All rights reserved.

Kent Hagerman

How I Stuffed my Laptop inside a K8s Pod

Page 2: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 3: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 4: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 5: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 6: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 7: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 8: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 9: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 10: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 11: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

11Copyright © Ciena Corporation 2019. All rights reserved.

Demo #1Laptop -> K8s Service

Page 12: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

12Copyright © Ciena Corporation 2019. All rights reserved.

Page 13: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

13Copyright © Ciena Corporation 2019. All rights reserved.

Demo #1Laptop -> K8s Service

Page 14: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 15: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 16: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 17: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 18: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 19: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 20: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

20Copyright © Ciena Corporation 2019. All rights reserved.

Demo #2K8s Service -> Laptop

Page 21: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

21Copyright © Ciena Corporation 2019. All rights reserved.

Page 22: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

22Copyright © Ciena Corporation 2019. All rights reserved.

Demo #2K8s Service -> Laptop

Page 23: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 24: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 25: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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]

Page 26: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 27: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 28: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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

Page 29: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

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.

Page 30: How I Stuffed my Laptop inside a K8s Pod€¦ · 03/09/2019  · •K8s services reachable •Build-run-test directly on laptop •Entire kubernetes environment available ... Voltha-ro-core

30Copyright © Ciena Corporation 2019. All rights reserved.

Questions?

Tool repo: github.com/kent-h/k8s-become-pod