k8s的快速使用手册
一、快速搭建文档
一、初始化kubernete
kubeadm init --kubernetes-version=v1.14.0 --pod-network-cidr=10.244.0.0/ --apiserver-advertise-address=192.168.10.12 --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers
....
To start using your cluster, you need to run the following as a regular user: mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/ Then you can join any number of worker nodes by running the following on each as root: kubeadm join 192.168.10.12: --token 3s24j5.nh1fqex8kmekpmtf \
--discovery-token-ca-cert-hash sha256:62bcc3a657fd97cd6d5da14b293912234f0f14512bb4bf8d8be1023a69fc6f17
==========================
二、安装flannel网络
wget https://raw.githubusercontent.com/loverying/mykubernetes/master/kubect_install/kube-flannel.yaml
[root@master kubectyaml]# kubectl apply -f kube-flannel.yaml
podsecuritypolicy.extensions/psp.flannel.unprivileged created
clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.extensions/kube-flannel-ds-amd64 created
daemonset.extensions/kube-flannel-ds-arm64 created
daemonset.extensions/kube-flannel-ds-arm created
daemonset.extensions/kube-flannel-ds-ppc64le created
daemonset.extensions/kube-flannel-ds-s390x created
[root@master kubectyaml]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 2m43s v1.14.2
三、其他机器加入集群
kubeadm join 192.168.10.12: --token 3s24j5.nh1fqex8kmekpmtf \
--discovery-token-ca-cert-hash sha256:62bcc3a657fd97cd6d5da14b293912234f0f14512bb4bf8d8be1023a69fc6f17
[root@master kubectyaml]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 4m3s v1.14.2
node01 Ready <none> 27s v1.14.2
node02 Ready <none> 22s v1.14.2
四、部署 dashboard
wget https://raw.githubusercontent.com/loverying/mykubernetes/master/kubect_install/dashboard-admin_new.yaml
wget https://raw.githubusercontent.com/loverying/mykubernetes/master/kubect_install/kubernetes-dashboard.yaml
kubectl apply -f dashboard-admin_new.yaml
kubectl apply -f kubernetes-dashboard.yaml
五、部署ingress-nginx
wget https://raw.githubusercontent.com/loverying/mykubernetes/master/kubect_install/mandatory.yaml
kubectl apply -f mandatory.yaml 六、部署应用
)部署pod 提供后端服务
)部署service 是做负载均衡
)部署ingress-nginx 将负载均衡绑定在域名上 七、部署普罗米修斯监控(研究) 八、日志收集平台(研究)
EFK平台
[root@master mykubernetes-master]# kubectl get pods -n ingress-nginx
NAME READY STATUS RESTARTS AGE
nginx-ingress-controller-5694ccb578-78ldg / Running 23d
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/baremetal/service-nodeport.yaml
[root@master ~]# kubectl get svc -n ingress-nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx NodePort 10.108.108.196 <none> :/TCP,:/TCP 76s
二、部署应用
1.1)部署pod
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myapp
namespace: default
labels:
app: myapp
spec:
replicas:
selector:
matchLabels:
app: myapp
template:
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: myapp
image: ikubernetes/myapp:v1
ports:
- name: http
containerPort:
mypod.yaml
1.2)访问效果
[root@master ~]# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
myapp-8w7bm / Running 10m 10.244.2.7 node02 <none> <none>
myapp-n4xhs / Running 10m 10.244.1.8 node01 <none> <none>
[root@master ~]# curl 10.244.2.7/hostname.html
myapp-8w7bm
[root@master ~]# curl 10.244.1.8/hostname.html
myapp-n4xhs
2.1)创建service
apiVersion: v1
kind: Service
metadata:
name: myapp
namespace: default
spec:
selector:
app: myapp
clusterIP: 10.99.99.99
type: NodePort
ports:
- port:
targetPort:
nodePort:
svc_mypod.yaml
2.2) 访问效果
[root@master ~]# kubectl get svc -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
kubernetes ClusterIP 10.96.0.1 <none> /TCP 3h10m <none>
myapp NodePort 10.99.99.99 <none> :/TCP 8m15s app=myapp
[root@master ~]# while true;do curl 192.168.10.12:/hostname.html;sleep ;done
myapp-8w7bm
myapp-n4xhs
myapp-n4xhs
myapp-8w7bm
myapp-8w7bm
vd--xxxx
[root@apaas-master0001 ~]# kubectl get svc -n enos vd-server -o yaml
apiVersion: v1
kind: Service
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"creationTimestamp":"2019-07-22T08:59:19Z","labels":{"app":"vd-server","appId":""},"name":"vd-server","namespace":"enos","resourceVersion":"","selfLink":"/api/v1/namespaces/enos/services/vd-server","uid":"fdc93ba3-ac5e-11e9-91e6-000d3aa15f2a"},"spec":{"clusterIP":"10.254.32.86","ports":[{"name":"tcp-8080","port":,"protocol":"TCP","targetPort":}],"selector":{"app":"vd-server"},"sessionAffinity":"None","type":"ClusterIP"},"status":{"loadBalancer":{}}}
creationTimestamp: --06T08::16Z
labels:
app: vd-xxxx
appId: ""
name: vd-xxxx
namespace: enos
resourceVersion: ""
selfLink: /api/v1/namespaces/enos/services/vd-xxxx
uid: 745b1906--11ea-b132-000d3aa1f771
spec:
clusterIP: 10.254.32.86
ports:
- name: tcp-
port:
protocol: TCP
targetPort:
selector:
app: vd-xxxx
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
svc
域名链接
3.1)创建 ingress
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-myapp
namespace: default
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: master.com
http:
paths:
- backend:
serviceName: myapp
servicePort:
ingress_pod.yaml
3.2 ) 访问效果测试
[root@master ~]# kubectl get ingress
NAME HOSTS ADDRESS PORTS AGE
ingress-myapp master.com 10m
[root@master ~]# kubectl describe ingress ingress-myapp
.......
[root@master ~]# while true;do curl master.com:/hostname.html;sleep ;done
myapp-8w7bm
myapp-n4xhs
myapp-n4xhs
myapp-8w7bm
三、资源获取(metrics-server)
1)安装metrics-server
https://github.com/baishuchao/kubernetes/tree/master/metrics-server
[root@ks-master k8s]# git clone https://github.com/baishuchao/kubernetes.git
[root@ks-master k8s]# cd kubernetes/metrics-server
[root@ks-master metrics-server]#kubectl apply -f .
2)资源获取示例
[root@master dashboard]# kubectl top pods -n kube-system
NAME CPU(cores) MEMORY(bytes)
coredns-d5947d4b-45r9x 5m 15Mi
coredns-d5947d4b-snsjt 6m 15Mi
etcd-master 53m 145Mi
kube-apiserver-master 83m 276Mi
kube-controller-manager-master 23m 54Mi
kube-flannel-ds-amd64-x6pcr 2m 16Mi
kube-flannel-ds-amd64-xntt5 4m 18Mi
kube-flannel-ds-amd64-zsq6r 4m 20Mi
kube-proxy-v67qd 12m 20Mi
kube-proxy-zg6ws 9m 20Mi
kube-proxy-zkmgh 9m 24Mi
kube-scheduler-master 2m 18Mi
kubernetes-dashboard-b6dcb8878-ckcz5 0m 0Mi
metrics-server-7579f696d8-kv8hs 1m 14Mi
k8s的快速使用手册的更多相关文章
- Github快速入门手册
最近在试用Github,开源的思想也让人觉得把一些经验分享出来是非常好的事情.附件是doc文件,如有需要请注意查收.希望能对你有帮助. GITHUB基于互联网的版本控制快速入门手册 如有不妥,欢迎指正 ...
- H3 BPM J.V10.6.1 安装及快速使用手册
直接进入地址下载:http://bbs.h3bpm.com/read.php?tid=3103&fid=30,需要注册. 按照文档"H3 BPM J.V10.6.1 安装及快速使用手 ...
- 2. Apache Axis2 快速学习手册之概览
这篇博文和大家一起学习下Apache Axis2 官方文档的快速指南篇 英文原文:http://axis.apache.org/axis2/java/core/docs/quickstartguide ...
- kubernetes(K8S)快速安装与配置集群搭建图文教程
kubernetes(K8S)快速安装与配置集群搭建图文教程 作者: admin 分类: K8S 发布时间: 2018-09-16 12:20 Kubernetes是什么? 首先,它是一个全新的基于容 ...
- (私人收藏)[开发必备]最全JQuery离线快速查找手册(可查询可学习,带实例)
[开发必备]最全JQuery离线快速查找手册(可查询可学习,带实例) https://pan.baidu.com/s/16bUd4iA3p0c5RHbzaC60IQe4zh
- (私人收藏)[开发必备]最全Java离线快速查找手册(可查询可学习,带实例)
(私人收藏)[开发必备]最全Java离线快速查找手册(可查询可学习,带实例) https://pan.baidu.com/s/1L54VuFwCdKVnQGVc8vD1TQnwmj java手册 Ja ...
- 在 K8S 中快速部署 Redis Cluster & Redisinsight
Redis Cluster 部署 使用 Bitnami helm chart 在 K8S redis 命名空间中一键部署 Redis cluster . helm repo add bitnami h ...
- React JS快速开始手册
怎样用React JS构建一个用户界面?本文将快速地给你一个React JS的概览.代码,请君移步react-starter 概念 React只有很少的API,这使得它很容易去学习与理解.当然,使用它 ...
- K8S环境快速部署Kafka(K8S外部可访问)
欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...
随机推荐
- macos系统安装mysql
MacOS系统安装mysql 一.下载 官网下载链接地址:https://dev.mysql.com/downloads/mysql/ 二.安装 打开文件是pkg包,双击进行安装: 按照提示: 点击最 ...
- 微信小程序(11)--购物车
今天记录一下购物车案例,实现购物车的全选,单选,数量加一减一,金额总数,以及清空购物车. <view class="main"> <!-- hasList 列表是 ...
- [AtCoder] Yahoo Programming Contest 2019
[AtCoder] Yahoo Programming Contest 2019 很遗憾错过了一场 AtCoder .听说这场是涨分场呢,于是特意来补一下题. A - Anti-Adjacency ...
- linux下安装maven私服nexus
Nexus介绍 Nexus 是Maven仓库管理器,如果你使用Maven,你可以从Maven中央仓库 下载所需要的构件(artifact),但这通常不是一个好的做法,你应该在本地架设一个Maven仓库 ...
- 大数据之hadoop框架知识
https://blog.csdn.net/zytbft/article/details/79285500
- Python格式输出汇总
print ('%10s'%('test')) print ('{:<10}'.format('test'))#left-aligned print ('{:>10}'.format('t ...
- axios拦截器的使用方法
很多时候我们需要在发送请求和响应数据的时候做一些页面处理,比如在请求服务器之前先判断以下用户是登录(通过token判断),或者设置请求头header,或者在请求到数据之前页面显示loading等等,还 ...
- BZOJ 4238 电压 解题报告
BZOJ 4238 电压 考虑一条边成为答案以后,删去Ta后剩下的图是一个或很多个二分图,即没有奇环 则一条边可以成为答案,当且仅当自己在所有奇环的交上且不在偶环上. 考虑建出dfs树,那么返祖边一定 ...
- HDU 6069 Counting Divisors —— 2017 Multi-University Training 4
Counting Divisors Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Oth ...
- C# webbrowser专题
C# .Net 2.0实例学习:WebBrowser页面与WinForm交互技巧 2 Study Case :高亮显示 上一个例子中我们学会了查找文本——究跟到底,对Web页面还是只读不写.那么,如果 ...