Kubernetes Connecting external data sources

Source: Internet
Author: User
Tags docker ps etcd

The core issue in Kubernetes architecture is how data is persistance, although it provides persistent volumn, but it is difficult to run and manage products like databases in a kubernetes cluster environment. Kubernetes provides endpoints this mode to map external services into internal services, which solves the problem of cluster external connection,

If we are going to connect an Oracle database outside, here are the steps:

    • Establish endpoints and service.
[email protected] jdbcservice]# cat jdbc-endpoint.yaml apiVersion:v1kind:Endpointsmetadata:  Name: Jdbcsubsets:  - addresses:    10.182.  168.244    ports:    1521      protocol:tcp

For convenience, we fixed the service's cluster address

[Email protected]Master jdbcservice]# cat Jdbcservice.yaml apiVersion:v1kind:Servicemetadata:  Name: Jdbcspec:  10.254. 150.201   ports:  1521     1521 protocol:tcp    

It is important to note that the name of the service and endpoints is the same, and if the service is delete. Re-establish the endpoints to build it again.

In this service table, we see that the JDBC service is tied to the 201 address.

[Email protected] jdbcservice]# KubectlGetservicesname CLUSTER-ip external-IP PORT (S) agehelloworldsvc10.254.43.122<nodes>7001:30001/TCP 12mjdbc10.254.150.201<none>1521/TCP 30mkubernetes10.254.0.1<none>443/TCP 121dregistry10.254.174.54<nodes> the:30002/tcp 20h

    • Configuration of the images

We then configured the JDBC configuration for our WebLogic images.

Click on test Configuration, if testing however, WebLogic does not allow the connection pool to be established successfully.

Run Docker PS on the node running the pod to find the container ID of the boot image.

[[Email protected]1~]# Docker pscontainer ID IMAGE COMMAND CREATED STATUS PORTS Namesd2c1dc2a2cef1213-helloworld:v1"startweblogic.sh"       7Minutes ago Up7Minutes k8s_weblogichelloworld.9efb3a79_helloworld-service-vfd10_default_6162d68a-9da9-11e7-b74 6-08002797edef_026d2cc485e04042041a registry.access.redhat.com/rhel7/pod-infrastructure:latest"/pod"                   7Minutes ago Up7Minutes k8s_pod.15c40ba1_helloworld-service-vfd10_default_6162d68a-9da9-11e7-b746-08002797edef_b59984a796acfd65eb3a Registry"/entrypoint.sh/etc/"    atMinutes ago Up atMinutes k8s_registry.71ab5625_registry-7nj8q_default_19ab0b7f-9cff-11e7-bf9d-08002797edef_fb5ae62063652932256c registry.access.redhat.com/rhel7/pod-infrastructure:latest"/pod"                    atMinutes ago Up atMinutes k8s_pod.100f0b9e_registry-7nj8q_default_19ab0b7f-9cff-11e7-bf9d-08002797edef_98dd7f3f1ed61c53625f Gcr.io/GOOGLE_CONTAINERS/ETCD-AMD64:2.2.1                    "/usr/local/bin/etcd"    -Minutes ago Up -Minutes k8s_etcd.bb974d90_kube-dns-v11-x0vr3_kube-system_5dd26461-3ef1-11e7-acf2-08002797EDEF_7316989CFB8545A4ABA4 Gcr.io/google_containers/exechealthz:1.0                     "/exechealthz '-cmd=n"    -Minutes ago Up -Minutes k8s_healthz.525e4aad_kube-dns-v11-x0vr3_kube-system_5dd26461-3ef1-11e7-acf2-08002797edef_cec4d740aa6c4caf3fa7 Gcr.io/google_containers/skydns: --Ten- --8c72f8c"/skydns-machines=ht"    -Minutes ago Up -Minutes k8s_skydns.96837166_kube-dns-v11-x0vr3_kube-system_5dd26461-3ef1-11e7-acf2-08002797edef_5da89b815930dae5b843 registry.access.redhat.com/rhel7/pod-infrastructure:latest"/pod"                    -Minutes ago Up -Minutes k8s_pod.4efc54ff_kube-dns-v11-x0vr3_kube-system_5dd26461-3ef1-11e7-acf2-08002797edef_3e3 af088

Create a new images

[[Email protected]1"jdbc""ericnie"1213 -helloworld-jdbc:v1sha256:953e124483d2bcc03b3f46c8e6d935e3746634d78942cc477e31888c8d569171

    • Verify

Modify WebLogic replication control to point to 1213-HELLOWORLD-JDBC:V1 images, and then start to see the connection established.

WebLogic End

Database-side

The original JDBC link on the database side

The connection after the pod is fully started

Kubernetes Connecting external data sources

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.