- Host network: 192.168.0.0/24
- Service network: 10.0.0.0/16
- Pod network: 172.16.0.0/16
- master01: 192.168.0.1
- master02: 192.168.0.2
- master03: 192.168.0.3
- pgsql-master: 192.168.0.10
- pgsql-slave: 192.168.0.11
- kubernetes: 10.0.0.1
- dns: 10.0.0.254
export DATABASE_URL='postgresql://application@192.168.0.10:5432/production_db'
export DATABASE_URL='postgresql://application@192.168.0.11:5432/production_db'
- You should resetup ALL related deployments and restart ALL theirs pods for hosted service address reconfiguration
postgres IN A 192.168.0.10
export DATABASE_URL="postgresql://application@postgres.somezone.tld:5432/production_db"
- update DNS record
- Remember about DNS cache
- Actually it is easier to kill all related pods
Use force endpoints and services, Luke!
$ kubectl get endpoints kubernetes
NAME ENDPOINTS AGE
kubernetes 192.168.0.1:8443,192.168.0.2:8443,192.168.0.3:8443 1y
$ kubectl get service kubernetes
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.0.0.1 none 443/TCP 1y
apiVersion: v1
kind: Endpoints
metadata:
name: kubernetes
namespace: default
subsets:
- addresses:
- ip: 192.168.0.1
- ip: 192.168.0.2
- ip: 192.168.0.3
ports:
- name: https
port: 8443
protocol: TCP
apiVersion: v1
kind: Service
metadata:
labels:
component: apiserver
provider: kubernetes
name: kubernetes
namespace: default
spec:
clusterIP: 10.0.0.1
ports:
- name: https
port: 443
protocol: TCP
targetPort: 8443
type: ClusterIP
apiVersion: v1
kind: Endpoints
metadata:
name: postgres
namespace: hosted
subsets:
- addresses:
- ip: 192.168.0.10
ports:
- name: postgres
port: 5432
protocol: TCP
apiVersion: v1
kind: Service
metadata:
name: postgres
namespace: hosted
spec:
ports:
- name: postgres
port: 5432
protocol: TCP
targetPort: 5432
type: ClusterIP
export DATABASE_URL='postgresql://application@postgres.hosted.cluster.local:5432/production_db'
- Service address is rock solid
- Service IP can be preserved in service manifest
- Any host network reconfiguration is just endpoint upgrade
- Endpoint upgrade is rocket fast -
kube-proxy
rocks!