符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
Kubernetes部署(一):架构及功能说明
Kubernetes部署(二):系统环境初始化
Kubernetes部署(三):CA证书制作
Kubernetes部署(四):ETCD集群部署
Kubernetes部署(五):Haproxy、Keppalived部署
Kubernetes部署(六):Master节点部署
Kubernetes部署(七):Node节点部署
Kubernetes部署(八):Flannel网络部署
Kubernetes部署(九):CoreDNS、Dashboard、Ingress部署
Kubernetes部署(十):储存之glusterfs和heketi部署
Kubernetes部署(十一):管理之Helm和Rancher部署
Kubernetes部署(十二):helm部署harbor企业级镜像仓库
创新互联是一家专注于网站制作、成都做网站与策划设计,镇巴网站建设哪家好?创新互联做网站,专注于网站建设十多年,网设计领域的专业建站公司;建站业务涵盖:镇巴等地区。镇巴做网站价格咨询:028-86922220
所有的软件及配置文件都保存在前面文章提到的百度网盘里 :百度共享链接在此文章里
[root@node-01 k8s]# kubectl create -f coredns/coredns.yaml
serviceaccount/coredns created
clusterrole.rbac.authorization.k8s.io/system:coredns created
clusterrolebinding.rbac.authorization.k8s.io/system:coredns created
configmap/coredns created
deployment.extensions/coredns created
service/coredns created
[root@node-01 yaml]# kubectl get pod -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-5f94b495b5-58t47 1/1 Running 0 6m
coredns-5f94b495b5-wvcsg 1/1 Running 0 6m
然后我们就可以随便进入一个pod,去ping域名看dns是否可以正常解析。
[root@node-01 yaml]# kubectl get pod
NAME READY STATUS RESTARTS AGE
tomcat-7666b9764-mfgpb 1/1 Running 0 11h
[root@node-01 yaml]# kubectl exec -it tomcat-7666b9764-mfgpb -- /bin/sh
# ping baidu.com
PING baidu.com (220.181.57.216) 56(84) bytes of data.
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=1 ttl=54 time=37.2 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=2 ttl=54 time=37.0 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=3 ttl=54 time=36.6 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=4 ttl=54 time=37.9 ms
^C
--- baidu.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 36.629/37.230/37.958/0.498 ms
[root@node-01 yaml]# kubectl create -f dashboard/
[root@node-01 yaml]# kubectl cluster-info
Kubernetes master is running at https://10.31.90.200:6443
CoreDNS is running at https://10.31.90.200:6443/api/v1/namespaces/kube-system/services/coredns:dns/proxy
kubernetes-dashboard is running at https://10.31.90.200:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
https://10.31.90.200:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
用户名:admin 密码:admin 选择令牌模式登录。
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
操作完以上步骤就可以看到dashboard了。
Kubernetes中,Service资源和Pod资源的IP地址仅能用于集群网络内部的通信,所有的网络流量都无法穿透边界路由器(Edge Router)以实 现集群内外通信。尽管可以为Service使用NodePort或LoadBalancer类型通过节点引入外部流量,但它依然是4层流量转发,可用的负载均衡器也 为传输层负载均衡机制。
可以下载官方的mandatory.yaml
到本地安装
[root@node-01 ingress]# kubectl create -f mandatory.yaml
或者
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml
由于官方的ingress也只是一个pod并没有对外暴露IP和端口,所以我们需要为ingress创建一个对外暴露的service,暴露nodePort 20080和20443端口。对于想部署在生产环境的,可以单独拿2个node服务器来单独部署ingress controller,然后暴露80和443端口就可以了。
apiVersion: v1
kind: Service
metadata:
name: ingress-nginx
namespace: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
spec:
type: NodePort
ports:
- name: http
nodePort: 20080
port: 80
targetPort: 80
protocol: TCP
- name: https
nodePort: 20443
port: 443
targetPort: 443
protocol: TCP
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
然后在haproxy的backend中加入3个node 的20080和20443端口,不明白我的网络架构的请看这里,然后将www.cnlinux.club
的A记录
解析到10.31.90.200
listen ingress-80
bind 10.31.90.200:80
mode tcp
balance roundrobin
timeout server 15s
timeout connect 15s
server apiserver01 10.31.90.204:20080 check port 20080 inter 5000 fall 5
server apiserver02 10.31.90.205:20080 check port 20080 inter 5000 fall 5
server apiserver03 10.31.90.206:20080 check port 20080 inter 5000 fall 5
listen ingress-443
bind 10.31.90.200:443
mode tcp
balance roundrobin
timeout server 15s
timeout connect 15s
server apiserver01 10.31.90.204:20443 check port 20443 inter 5000 fall 5
server apiserver02 10.31.90.205:20443 check port 20443 inter 5000 fall 5
server apiserver03 10.31.90.206:20443 check port 20443 inter 5000 fall 5
[root@node-01 yaml]# kubectl create -f tomcat-demo.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat
labels:
app: tomcat
spec:
replicas: 1
selector:
matchLabels:
app: tomcat
template:
metadata:
labels:
app: tomcat
spec:
containers:
- name: tomcat
image: tomcat:latest
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: tomcat
spec:
selector:
app: tomcat
ports:
- name: tomcat
protocol: TCP
port: 8080
targetPort: 8080
type: ClusterIP
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: tomcat
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: www.cnlinux.club
http:
paths:
- path:
backend:
serviceName: tomcat
servicePort: 8080
至此ingress就已创建完成。在浏览器打开www.cnlinux.club 就可以看到tomcat的页面。
后续会陆续更新所有的k8s相关文档,如果你觉得我写的不错,希望大家多多关注点赞,非常感谢!