标签:add prot targe 服务 ati rip 技术分享 let gic
Kubernetes架构下比较核心的问题是数据如何persistance,虽然提供了Persistent volumn的方式,但是对于像数据库之类的产品在kubernetes集群环境中运行和管理还是很有难度的,Kubernetes提供了endpoints这种模式让外部的服务映射成内部的服务,这样比较好的解决了集群对外的连接问题,
如果我们去连接外部的一个oracle数据库,具体的步骤如下:
[root@k8s-master jdbcservice]# cat jdbc-endpoint.yaml apiVersion: v1 kind: Endpoints metadata: name: jdbc subsets: - addresses: - ip: 10.182.168.244 ports: - port: 1521 protocol: TCP
为了方便,我们固定了service的集群地址
[root@k8s-master jdbcservice]# cat jdbcservice.yaml apiVersion: v1 kind: Service metadata: name: jdbc spec: clusterIP: 10.254.150.201 ports: - port: 1521 targetPort: 1521 protocol: TCP
需要注意的是,service和endpoints的名字要相同,另外如果delete了service.再重新建立的时候要再把endpoints建立一遍。
在这个service的表里,我们看到jdbc服务绑在了201这个地址上。
[root@k8s-master jdbcservice]# kubectl get services NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE helloworldsvc 10.254.43.122 <nodes> 7001:30001/TCP 12m jdbc 10.254.150.201 <none> 1521/TCP 30m kubernetes 10.254.0.1 <none> 443/TCP 121d registry 10.254.174.54 <nodes> 5000:30002/TCP 20h
然后对我们的weblogic images进行jdbc的配置。
点击Test Configuration,如果测试不过,weblogic不允许建立连接池成功.
在运行pod的节点上运行docker ps找到启动image的容器id.
[root@k8s-node-1 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d2c1dc2a2cef 1213-helloworld:v1 "startWebLogic.sh" 7 minutes ago Up 7 minutes k8s_weblogichelloworld.9efb3a79_helloworld-service-vfd10_default_6162d68a-9da9-11e7-b746-08002797edef_026d2cc4 85e04042041a registry.access.redhat.com/rhel7/pod-infrastructure:latest "/pod" 7 minutes ago Up 7 minutes k8s_POD.15c40ba1_helloworld-service-vfd10_default_6162d68a-9da9-11e7-b746-08002797edef_b59984a7 96acfd65eb3a registry "/entrypoint.sh /etc/" 23 minutes ago Up 23 minutes k8s_registry.71ab5625_registry-7nj8q_default_19ab0b7f-9cff-11e7-bf9d-08002797edef_fb5ae620 63652932256c registry.access.redhat.com/rhel7/pod-infrastructure:latest "/pod" 23 minutes ago Up 23 minutes k8s_POD.100f0b9e_registry-7nj8q_default_19ab0b7f-9cff-11e7-bf9d-08002797edef_98dd7f3f 1ed61c53625f gcr.io/google_containers/etcd-amd64:2.2.1 "/usr/local/bin/etcd " 47 minutes ago Up 47 minutes k8s_etcd.bb974d90_kube-dns-v11-x0vr3_kube-system_5dd26461-3ef1-11e7-acf2-08002797edef_7316989c fb8545a4aba4 gcr.io/google_containers/exechealthz:1.0 "/exechealthz ‘-cmd=n" 47 minutes ago Up 47 minutes k8s_healthz.525e4aad_kube-dns-v11-x0vr3_kube-system_5dd26461-3ef1-11e7-acf2-08002797edef_cec4d740 aa6c4caf3fa7 gcr.io/google_containers/skydns:2015-10-13-8c72f8c "/skydns -machines=ht" 47 minutes ago Up 47 minutes k8s_skydns.96837166_kube-dns-v11-x0vr3_kube-system_5dd26461-3ef1-11e7-acf2-08002797edef_5da89b81 5930dae5b843 registry.access.redhat.com/rhel7/pod-infrastructure:latest "/pod" 47 minutes ago Up 47 minutes k8s_POD.4efc54ff_kube-dns-v11-x0vr3_kube-system_5dd26461-3ef1-11e7-acf2-08002797edef_3e3af088
生成新的images
[root@k8s-node-1 ~]# docker commit -m "jdbc" -a "ericnie" d2c1dc2a2cef 1213-helloworld-jdbc:v1 sha256:953e124483d2bcc03b3f46c8e6d935e3746634d78942cc477e31888c8d569171
修改weblogic replication control指向1213-helloworld-jdbc:v1 images,启动后看到连接建立.
weblogic端
数据库端
数据库端原来的jdbc链接
Pod完全启动后的连接
标签:add prot targe 服务 ati rip 技术分享 let gic
原文地址:http://www.cnblogs.com/ericnie/p/7560280.html