kubernetes Demo 环境搭建

国内k8s源被墙,找了在线的实验环境

https://labs.play-with-k8s.com/

clipboard

clipboard

跑2条命令

1. Initializes cluster master node:

kubeadm init --apiserver-advertise-address $(hostname -i)

2. Initialize cluster networking:

kubectl apply -n kube-system -f \

"https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 |tr -d '\n')"

这条随意

3. (Optional) Create an nginx deployment:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/application/nginx-app.yaml

clipboard

clipboard

#下载示例代码

yum install -y git && git clone https://github.com/pcdogyu/kubernetes-example-voting-app.git

创建投票的pod

kubectl create -f voting-app-pod.yml

clipboard

看下pods起来了么

kubectl get pods

clipboard

pending状态啊,容我查看

kubectl describe pods

clipboard

节点不可用

clipboard

kubectl get nodes

确实没有只有一个master,master无法host pod

clipboard

kubectl taint nodes node1 node-role.kubernetes.io/master:NoSchedule-

clipboard

kubectl get pods

clipboard

pod跑起来了,下面创建一个services

kubectl create -f voting-app-service.yml

clipboard

kubectl get services

clipboard

服务起来鸟,下面创建redis+postgreSQL的 pod和服务

kubectl create -f redis-pod.yml

kubectl create -f redis-service.yml

kubectl create -f postgres-pod.yml

kubectl create -f postgres-service.yml

clipboard

创建投票和显示的页面

kubectl create -f worker-app-pod.yml

kubectl create -f result-app-pod.yml

kubectl create -f result-app-service.yml

clipboard

看下pod都好了么,妈的免费机器就是卡

kubectl get pods

clipboard

#后期有一个很暴力的命令,把当前目录下的yml依次创建

kubectl create -f .

猜你喜欢

转载自blog.51cto.com/433266/2478288