Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Orchestrating Containers
Kubernetes - Learning Continues
Eueung Mulyana
http://eueung.github.io/docker-stuff/learning-k8s
CodeLabs | Attribution-ShareAlike CC BY-SA
1 / 37
Outline
Base Setup & OS Con g
k8s Addons - DNS & Dashboard
Remote Master & k8s Visualizer
Test It All
2 / 37
Base Setup & OS Config
3 / 37
4 / 37
node1 RPI 3
192.168.1.102
node2 RPI 2
192.168.1.101
node3 RPI 2
192.168.1.100
5 / 37
HypriotOS
0.8.0
$flash-d/dev/mmcblk0hypriotos-rpi-v0.8.0.img
$flash-d/dev/mmcblk0hypriotos-rpi-v0.8.0.img
$ssh-keygen-f"/home/em/.ssh/known_hosts"-Rblack-pearl.loc
$sshpirate@black-pearl.local
#pirate/hypriot
$sudonano/etc/network/interfaces.d/eth0
$sudonano/etc/hosts
$sudonano/etc/hostname
#---
$sudonano/boot/device-init.yaml
#hostnameforyourHypriotOSdevice
hostname:node2
docker:
images:
-"/var/local/rpi-consul_v0.6.4.tar.gz"
-"/var/local/rpi-swarm_v1.2.2.tar.gz"
clusterlab:
service:
run_on_boot:"false"
#optionalwirelessnetworksettings
wifi:
interfaces:
# wlan0:
# ssid:"MyNetwork"
# password:"secret_password"
6 / 37
HypriotOS
0.8.0
$sudosu
$mount-oremount,rw/sys/fs/cgroup
$mkdir/sys/fs/cgroup/cpuset
$nano/boot/cmdline.txt
#edit:cgroup_enable=cpuset
#---
$nano/etc/resolv.conf
searchdefault.svc.cluster.localsvc.cluster.localcluster.loc
nameserver10.0.0.10
nameserver192.168.1.1
#---
#optionaltools
$apt-getinstalldnsutilszip
$shutdown-rnow
#---
$ssh-keygen-R192.168.1.101&&ssh-keygen-Rnode2.local
$ssh-copy-id-oStrictHostKeyChecking=no-oCheckHostIP=nopira
$sftppirate@node2.local
#putimages...
#putkube-systemd...
7 / 37
kubernetes-on-arm v0.7.0
$dpkg-ikube-systemd.deb
$kube-configinstall
#rpiorrpi-2,hypriotos
$gzip-dcimages.tar.gz|dockerload
$kube-configinfo
$kube-configenable-master
$kube-configenable-worker192.168.1.102
k8s Addons
DNS & Dashboard
8 / 37
$sudokube-configenable-addondashboard
$sudokube-configenable-addondns
namespace"kube-system"created
Warning:Unitfileofnetworking.servicechangedondisk,'systemctldaemon-reload'reco
replicationcontroller"kube-dns-v8"created
service"kube-dns"created
Startedaddon:dns
$kubectlcluster-info
Kubernetesmasterisrunningathttp://localhost:8080
KubeDNSisrunningathttp://localhost:8080/api/v1/proxy/namespaces/kube-system/services
Dashboardisrunningathttp://localhost:8080/api/v1/proxy/namespaces/kube-system/servic
$kubectl--namespace=kube-systemgetpods,rc,svc
NAME READY STATUS RESTARTS AGE
kube-dns-v8-uv6r5 4/4 Running 0 1h
kubernetes-dashboard-h5g84 1/1 Running 0 1h
NAME DESIRED CURRENT AGE
kube-dns-v8 1 1 22h
kubernetes-dashboard 1 1 22h
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kube-dns 10.0.0.10 <none> 53/UDP,53/TCP 22h
kubernetes-dashboard 10.0.0.249 <none> 80/TCP 22h
9 / 37
Master
#ksp-restart.sh
#---
#!/bin/bash
kubectldeletepo$(kubectlgetpo--namespace=kube-system|grepkube-dns|cut-d''
kubectldeletepo$(kubectlgetpo--namespace=kube-system|grepdashboard|cut-d''
10 / 37
Restart Pods
$kubectl--namespace=kube-systemgetpo
NAME READY STATUS RESTARTS AGE
kube-dns-v8-8dk0a 4/4 Running 0 11s
kubernetes-dashboard-ew4ec 1/1 Running 0 21s
$kubectllogs--namespace=kube-systemkube-dns-v8-8dk0a-ckube2sky
I053123:29:01.131613 1kube2sky.go:462Etcdserverfound:http://127.0.0.1:4001
I053123:29:02.225877 1kube2sky.go:529Usinghttps://10.0.0.1:443forkubernetes
I053123:29:02.226027 1kube2sky.go:530UsingkubernetesAPI<nil>
I053123:29:02.231187 1kube2sky.go:598Waitingforservice:default/kubernetes
I053123:29:03.431233 1kube2sky.go:660SuccessfullyaddedDNSrecordforKubernet
$kubectl--namespace=kube-systemexec-tikube-dns-v8-8dk0a--nslookupkubernetes.defa
...
$kubectl--namespace=kube-systemexec-tikube-dns-v8-8dk0a--cat/etc/hosts
$kubectl--namespace=kube-systemexec-tikube-dns-v8-8dk0a--cat/etc/resolv.conf
11 / 37
Check
DNS Service
#luxas/addons/sleep.yaml
apiVersion:v1
kind:Pod
metadata:
name:alpine-sleep
namespace:default
spec:
containers:
-image:luxas/alpine
command:
-sleep
-"3600"
imagePullPolicy:IfNotPresent
name:alpine-sleep
restartPolicy:Always
---
apiVersion:v1
kind:Pod
metadata:
name:raspbian-sleep
namespace:default
spec:
containers:
-image:resin/rpi-raspbian:jessie
command:
-sleep
-"3600"
imagePullPolicy:IfNotPresent
name:raspbian-sleep
restartPolicy:Always
12 / 37
Test
DNS Service
$kubectlcreate-fsleep.yaml
$kubectlexec-italpine-sleep--nslookupkubernetes.default10.0.0.10
$kubectlexec-italpine-sleep--nslookupkubernetes10.0.0.10
$kubectlexec-italpine-sleep--nslookupkube-dns.kube-system.svc.cluster.local10.0
$kubectlexec-italpine-sleep--nslookupkubernetes-dashboard.kube-system.svc.cluster
Server: 10.0.0.10
Address1:10.0.0.10
Name: kubernetes-dashboard.kube-system.svc.cluster.local
Address1:10.0.0.249
13 / 37
Test
DNS Service
#fromWorker/Minion
pirate@node2in~
$curl-khttps://kubernetes.default.svc.cluster.local
$curl-khttps://kubernetes
{
"paths":[
"/api",
"/api/v1",
"/apis",
"/apis/autoscaling",
"/apis/autoscaling/v1",
"/apis/batch",
"/apis/batch/v1",
"/apis/extensions",
"/apis/extensions/v1beta1",
"/healthz",
"/healthz/ping",
"/logs/",
"/metrics",
"/resetMetrics",
"/swagger-ui/",
"/swaggerapi/",
"/ui/",
"/version"
]
}
14 / 37
Test
DNS Service
Dashboard
 
15 / 37
Dashboard
 
16 / 37
Dashboard
 
17 / 37
Dashboard
 
18 / 37
Dashboard
 
19 / 37
Remote Master & k8s Visualizer
20 / 37
$wgethttps://storage.googleapis.com/kubernetes-release/release/v1.2.0/bin/linux/amd64/kubectl
$chmod+xkubectl&&sudomvkubectl/usr/local/bin/
$kubectlconfigset-clusterlk8--server=http://192.168.1.102:8080
$kubectlconfigset-contextlk8--cluster=lk8
$kubectlconfiguse-contextlk8
$kubectlgetnodes
NAME STATUS AGE
192.168.1.100 Ready 3d
192.168.1.101 Ready 3d
192.168.1.102 Ready 3d
21 / 37
Remote
Master
$gitclonehttps://github.com/saturnism/gcp-live-k8s-visualizer.gitk8s-visualizer
$cdk8s-visualizer
$kubectlproxy--www=.
Startingtoserveon127.0.0.1:8001
22 / 37
k8s
Visualizer
k8s Visualizer
 
23 / 37
Test It All
24 / 37
$kubectlrunhello-kube--image=hypriot/rpi-nano-httpd --port=80-lvisualize=true,run
deployment"hello-kube"created
$kubectlexposedeploymenthello-kube--type="LoadBalancer"--external-ip="192.168.1.10
service"hello-kube"exposed
#anynodeeth0address:102,101,100
$kubectlgetsvc
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-kube 10.0.0.157 ,192.168.1.102 80/TCP 37s
kubernetes 10.0.0.1 <none> 443/TCP 3d
$kubectlgetpo-owide
NAME READY STATUS RESTARTS AGE NODE
alpine-sleep 1/1 Running 0 1h 192.168.1.102
hello-kube-658934829-o6ka3 1/1 Running 0 2m 192.168.1.101
k8s-master-192.168.1.102 4/4 Running 3 2h 192.168.1.102
raspbian-sleep 1/1 Running 0 1h 192.168.1.102
25 / 37
Test #1
#fromnode3
$curl192.168.1.102
$curl10.0.0.157
$curlhello-kube
<html>
<head><title>PiarmedwithDockerbyHypriot</title>
<bodystyle="width:100%;background-color:black;">
<divid="main"style="margin:100pxauto0auto;width:800px;">
<imgsrc="pi_armed_with_docker.jpg"alt="piarmedwithdocker"style="width:800px
</div>
</body>
</html>
26 / 37
Test #1
Reachability
hello-kube Visualized
 
27 / 37
Test #2 via Dashboard
 
28 / 37
Test #2 via Dashboard
 
29 / 37
Test #2 - Take 2
 
30 / 37
Test #2 - Take 2
 
31 / 37
Test #2 - Visualizer
 
32 / 37
$kubectlgetpo-owide
NAME READY STATUS RESTARTS AGE NODE
alpine-sleep 1/1 Running 2 2h 192.168.1.102
k8s-master-192.168.1.102 4/4 Running 3 4h 192.168.1.102
my-nginx-afadx 1/1 Running 0 19m 192.168.1.100
my-nginx-e5coa 1/1 Running 0 19m 192.168.1.101
my-nginx2-68r7o 1/1 Running 0 6m 192.168.1.101
my-nginx2-pviak 1/1 Running 0 6m 192.168.1.100
raspbian-sleep 1/1 Running 2 2h 192.168.1.102
$kubectlgetsvc
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 10.0.0.1 <none> 443/TCP 3d
my-nginx2 10.0.0.138 8300/TCP 6m
$curlmy-nginx2:8300
<p>WELCOMETONGINX</p>
HypriotOS/armv7:pirate@node1in~
33 / 37
Test #2
Reachability
34 / 37
Refs
35 / 37
Refs
1. Docker Pirates ARMed with explosive stu
2. kubernetes-on-arm - by @luxas
3. k8s-visualizer @brendandburns @saturnism
4. Setting up Kubernetes visualization of a cluster - @rpicloud
36 / 37
END
Eueung Mulyana
http://eueung.github.io/docker-stuff/learning-k8s
CodeLabs | Attribution-ShareAlike CC BY-SA
37 / 37

More Related Content

Learning kubernetes