Kubernetes(1)Introduction and etcd

本文介绍如何在MacBook上安装Kubernetes及其组件etcd,并通过minikube搭建本地集群。此外,还介绍了Kubernetes的基本概念,如Pods、Services、ReplicationControllers等,以及如何使用kubectl进行集群管理和操作。
Kubernetes(1)Introduction and etcd

etcd - zookeeper
https://github.com/coreos/etcd/releases/

Install etcd on Mac Book
>brew install etcd

Start the Service
>etcd

Client command to test
>etcdctl member list
8e9e05c52164694d: name=default peerURLs=http://localhost:2380 clientURLs=http://localhost:2379 isLeader=true

Check API version
>etcdctl --version
etcdctl version: 3.3.1
API version: 2

Save one key-value
>ETCDCTL_API=3 etcdctl put foo bar
OK

Fetch one key-value
>ETCDCTL_API=3 etcdctl get foo
foo
bar

Document about the command
https://github.com/coreos/etcd/blob/master/etcdctl/README.md

Kubernetes
https://kubernetes.io/docs/tutorials/kubernetes-basics/
https://yeasy.gitbooks.io/docker_practice/content/kubernetes/concepts.html

Understand the Structure of Kubernetes
Kubernetes —— Operation Object —> pod, service, replication controller
—— Modules —> master (apiserver, scheduler, controller-manager), slave (proxy, kubelet)
Node - machine running
Pod - some apps running group, they will share one volume
Pos-states — status, when to restart and etc
Replication Controller — how many pods running at the same time
Services — provide services to outside of the world on top of pods
Volumes —
Labels
Accessing_the_api
Web (ux) — Kubernetes UI
Cli — Kubecfg command

Node - Docker, Kubelet, Proxy
Node period - Pending, Running, Terminated
Node status - Running, NodeReachable, NodeReady

Kubelet is the agent on working Node, it will do actions on working Node, and report the pod status.
Kube-proxy Load Balancer

Install Kubernetes
http://atbug.com/install-kubernetes-on-macos/#Kubernetes

Check my ENV
> sysctl -a | grep machdep.cpu.features | grep VMX
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX SMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C

Install VirtualBox
I already have the latest one, version 5.2.8 r121009

Install MiniKube
https://github.com/kubernetes/minikube/
> brew cask install minikube

It is downloading and installing https://storage.googleapis.com/minikube/releases/v0.25.2/minikube-darwin-amd64

After installation, it will show
> minikube version
minikube version: v0.25.2

> minikube start
Starting local Kubernetes v1.9.4 cluster...
Starting VM...
Downloading Minikube ISO

Install Kubectl
https://github.com/kubernetes/kubectl
https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl
Download the binary file first
> curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/darwin/amd64/kubectl

Give permission to that file
> chmod a+x ./kubectl

Copy to working directory
> sudo mv ./kubectl /usr/local/bin/kubectl

Check version
> kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-26T16:55:54Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"", Minor:"", GitVersion:"v1.9.4", GitCommit:"bee2d1505c4fe820744d26d41ecd3fdd4a3d6546", GitTreeState:"clean", BuildDate:"2018-03-21T21:48:36Z", GoVersion:"go1.9.1", Compiler:"gc", Platform:"linux/amd64"}

By default, kubectl configuration is located at ~/.kube/config

Check cluster information
> kubectl cluster-info
Kubernetes master is running at https://192.168.99.100:8443
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Enabling shell autocompletion
https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl
Check my current bash version
> bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
Copyright (C) 2007 Free Software Foundation, Inc.

> brew install bash-completion
> kubectl completion bash > $(brew --prefix)/etc/bash_completion.d/kubectl

Get the cluster IP
> minikube ip
192.168.99.100

Get the Service List
> minikube service list
|-------------|----------------------|-----------------------------|
| NAMESPACE | NAME | URL |
|-------------|----------------------|-----------------------------|
| default | kubernetes | No node port |
| kube-system | kube-dns | No node port |
| kube-system | kubernetes-dashboard | http://192.168.99.100:30000 |
|-------------|----------------------|-----------------------------|

Open the dash board
> minikube dashboard
Opening kubernetes dashboard in default browser...

UI
http://192.168.99.100:30000/#!/overview?namespace=default

List the Pods
> kubectl get pods --namespace kube-system
NAME READY STATUS RESTARTS AGE
kube-addon-manager-minikube 1/1 Running 0 4d
kube-dns-54cccfbdf8-hnp5x 3/3 Running 0 4d
kubernetes-dashboard-77d8b98585-kz27w 1/1 Running 0 4d
storage-provisioner 1/1 Running 0 4d

Check the detail for dashboard
> kubectl describe pod kubernetes-dashboard-77d8b98585-kz27w --namespace kube-system
Name: kubernetes-dashboard-77d8b98585-kz27w
Namespace: kube-system
Node: minikube/192.168.99.100
Start Time: Fri, 30 Mar 2018 15:20:37 -0500
Labels: addonmanager.kubernetes.io/mode=Reconcile
app=kubernetes-dashboard
pod-template-hash=3384654141
version=v1.8.1
Annotations: <none>
Status: Running
IP: 172.17.0.2

Check the logging
> kubectl logs -f kubernetes-dashboard-77d8b98585-kz27w --namespace kube-system


References:
https://yeasy.gitbooks.io/docker_practice/content/kubernetes/
https://github.com/kubernetes/kubernetes

etcd
https://yeasy.gitbooks.io/docker_practice/content/etcd/
https://github.com/coreos/etcd
https://yq.aliyun.com/articles/11035
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值