Kubernetes how to patch external address into service

How to make an service bind to host

Kubernetes how to patch external address into service
Page content

Introduction

This will be a quick short blog entry. Today I had an container running Oracle at Amazon EC2 on Kubernetes. I was trying to work thorugh some Pl/SQL code in sqlplus, and decided I wanted to instead use SQL Developer. After a little research this is what I came up with, and wanted to share it.

Bash Script

kubectl patch svc oracle -p '{"spec":{"externalIPs":["1.2.3.4"]}}'

Basically you pass the kubernetes service name, as well as your ip address of the host (in this example 1.2.3.4). If all goes well you will see on the next “kubectl get service” that service is now also bound to the host’s external address. From there you can connect to those ports on your hosts ip address rather than it being only a cluster address.

Hopefully this short little blog post helps someone out.