“K8s部署tomcat mysql 与ingress暴露服务”的版本间的差异

来自linux中国网wiki
跳转至: 导航搜索
(创建页面,内容为“<pre> [root@iZwz9ignqjb7qvobn1fuocZ tomcat]# ls mysql-rc.yaml mysql-svc.yaml myweb-rc.yaml myweb-svc.yaml [root@iZwz9ignqjb7qvobn1fuocZ tomcat]# kubectl create -…”)
 
第119行: 第119行:
  
 
</pre>
 
</pre>
 +
 +
[[category:k8s]]

2019年7月10日 (三) 22:46的版本

[root@iZwz9ignqjb7qvobn1fuocZ tomcat]# ls 
mysql-rc.yaml  mysql-svc.yaml  myweb-rc.yaml  myweb-svc.yaml
[root@iZwz9ignqjb7qvobn1fuocZ tomcat]# kubectl create -f  mysql-rc.yaml 
replicationcontroller/mysql created
[root@iZwz9ignqjb7qvobn1fuocZ tomcat]# kubectl get rc 
NAME    DESIRED   CURRENT   READY   AGE
mysql   1         1         0       10s
[root@iZwz9ignqjb7qvobn1fuocZ tomcat]# kubectl create -f  mysql-svc.yaml 
service/mysql created
[root@iZwz9ignqjb7qvobn1fuocZ tomcat]# kubectl get svc 
NAME                            TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)    AGE
kubernetes                      ClusterIP   172.21.0.1     <none>        443/TCP    52m
mysql                           ClusterIP   172.21.6.69    <none>        3306/TCP   12s
tailored-armadillo-hello-helm   ClusterIP   172.21.7.186   <none>        80/TCP     11m





[root@ tomcat]# kubectl create -f  myweb-rc.yaml 
replicationcontroller/myweb created

 kubectl get pods 
NAME                                            READY   STATUS    RESTARTS   AGE
mysql-fkkf7                                     1/1     Running   0          2m51s
myweb-fp4mz                                     1/1     Running   0          34s


[root@iZwz9ignqjb7qvobn1fuocZ tomcat]# kubectl get services
NAME                            TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
kubernetes                      ClusterIP   172.21.0.1     <none>        443/TCP          55m
mysql                           ClusterIP   172.21.6.69    <none>        3306/TCP         3m10s
myweb                           NodePort    172.21.4.96    <none>        8080:30001/TCP   17s
tailored-armadillo-hello-helm   ClusterIP   172.21.7.186   <none>        80/TCP           14m
[root@iZwz9ignqjb7qvobn1fuocZ tomcat]# kubectl get svc 
NAME                            TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
kubernetes                      ClusterIP   172.21.0.1     <none>        443/TCP          55m
mysql                           ClusterIP   172.21.6.69    <none>        3306/TCP         3m17s
myweb                           NodePort    172.21.4.96    <none>        8080:30001/TCP   24s
tailored-armadillo-hello-helm   ClusterIP   172.21.7.186   <none>        80/TCP           14m




当部署完成后,单击左侧导航栏中的路由与负载均衡 > 服务,找到wordpress服务并查看其外端端点


更新服务--> 负载均衡-->   服务端口 这里为30001 


[root@iZwz9ignqjb7qvobn1fuocZ tomcat]# kubectl get services
NAME                            TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)           AGE
kubernetes                      ClusterIP      172.21.0.1     <none>         443/TCP           68m
mysql                           ClusterIP      172.21.6.69    <none>         3306/TCP          15m
myweb                           LoadBalancer   172.21.4.96    119.23.93.84   30001:30001/TCP   12m




LoadBalancer  ip 
http://119.23.93.84:30001/demo/index.jsp

hosts

loadbalaip  a.com 



cat myweb.yml 

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: '2019-07-10T12:24:18Z'
  name: myweb
  namespace: default
  resourceVersion: '10862'
  selfLink: /api/v1/namespaces/default/services/myweb
  uid: a3912df1-a30d-11e9-886c-00163e107776
spec:
  clusterIP: 172.21.4.96
  externalTrafficPolicy: Local
  healthCheckNodePort: 30205
  ports:
    - name: myweb-svc
      nodePort: 30001
      port: 30001
      protocol: TCP
      targetPort: 8080
  selector:
    app: myweb
  sessionAffinity: None
  type: LoadBalancer
status:
  loadBalancer:
    ingress:
      - ip: 119.23.93.84


其实就是ingress 




实例间服务发现(Headless Service)