Say I have the following YAML representing a service:
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:us-west-2:91371:certificate/0a389f-4086-4db6-9106-b587c90a3
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "443"
labels:
app: main-api-prod
name: main-api-prod
spec:
type: LoadBalancer
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
- name: https
protocol: TCP
port: 443
targetPort: 80
selector:
app: main-api-prod
after I run:
kubectl apply -f <file>
I run:
kbc get svc -o json | grep hostname
and we see:
"hostname": "a392f200796b8b0279bdd390c-228227293.us-west-2.elb.amazonaws.com"
my question is - is there a way to tell kubectl
to use my own id in the hostname? In other words, I would like to tell it to use "abc" instead of "a392..", so it would be:
"abc-228227293.us-west-2.elb.amazonaws.com"
As an aside, if anyone knows what "228227293" represents, please lmk, I know that it is not our AWS accountid, that's for sure.
When you create a service of type "load balancer", a new load balancer is created by your cloud provider (here aws). Load Balancer naming is of the responsibility of the cloud provider. I don't think you can tell amazon how to generate the load balancer name. And it may depends of the load balancer type - alb, internal alb, nlb, ....
But you can use "external-dns" (https://github.com/kubernetes-incubator/external-dns). When configured for a dns providers - for exemple aws route53 - it can automatically creates dns aliases for your load balancer. But you won't be able to create name in amazonws.com domain ...