I want to set external-Ip as static. I succeed to make ClusterIP as static but I can not find any solution in anywhere for external_IP.
I use below deployment yaml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
creationTimestamp: null
generation: 1
labels:
run: x-master
name: x-deployment-master
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
run: x-master
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
run: x-master
spec:
containers:
- image: gitlab:4567/ecoservers/x-docker:x
imagePullPolicy: IfNotPresent
name: x-master
volumeMounts:
- name: task-pv-storage
mountPath: /opt/y/x/home/configutil
ports:
- containerPort: 8009
protocol: TCP
- containerPort: 8443
protocol: TCP
- containerPort: 8445
protocol: TCP
- containerPort: 9000
protocol: TCP
- containerPort: 7600
protocol: UDP
- containerPort: 12001
protocol: TCP
volumes:
- name: task-pv-storage
hostPath:
path: /root/configs/configutil_master
type: Directory
hostAliases:
- ip: 10.233.0.13
hostnames:
- gessmsatf1
- ip: 10.233.0.13
hostnames:
- gessmsatf2
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status: {}
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
run: x-master
name: x-service-master
selfLink: /api/v1/namespaces/default/services/x-service-master
spec:
externalTrafficPolicy: Cluster
ports:
- name: "gui-port"
protocol: TCP
port: 8443
targetPort: 8443
- name: "service-port"
protocol: TCP
port: 8445
targetPort: 8445
- name: "cu-port"
protocol: TCP
port: 9000
targetPort: 9000
- name: "ajp-port"
protocol: TCP
port: 8009
targetPort: 8009
- name: "cluster-7600"
protocol: TCP
port: 7600
targetPort: 7600
- name: "cluster-12001"
protocol: TCP
port: 12001
targetPort: 12001
clusterIP: 10.233.0.13
loadBalancerIP: 10.233.0.13
selector:
run: x-master
sessionAffinity: None
type: LoadBalancer
status:
loadBalancer:
ingress:
- ip: 10.233.0.13
actual result like this:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
x-service-master LoadBalancer 10.233.0.13 <pending> 8443:30013/TCP 175m
expected result shoul be : NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
helloweb 10.31.254.176 203.0.113.32 80:30690/TCP 54s
Kubernetes itself does not provide load balancing
When you specified the service definition you set a type of loadbalancer, which is actually provided by a cloud provider function (Which is most cases is handled by the VPS provider. AWS uses Elastic Load Balancers, Azure uses their TCP Load balancers etc). In those scenarios, you would rarely also specify the IP Address
If you rolled your own Kubernetes on a cloud provider that already offered a service, you're better off just using the service. If you're in a private datacenter, you'll want to deploy metallb and then nat services down to it.
Does using NodePort as the type resolve your issue at all?
Kubernetes not provide any IP as static IP or external IP. If you are using the AWS, GCP as service you can create service type LoadBalancer
so it will provide you one external IP that can be used as the external IP adress.
You can also search for ingress in kubernetes.it will also help in future to setup the SSL certificate for your application and multiple website inside one kubernetes cluster.
https://kubernetes.io/docs/concepts/services-networking/ingress/