我能够在Kubernetes中获取服务的公共DNS名称,但不能在Openshift中获取。这是非常基本的事情,我不知道为什么它不起作用?我附加了用于创建应用和服务器的清单文件。它不适用于openshift。
kubectl apply -f prometheus-configmap.yml
kubectl apply -f prometheus-rbac.yml
kubectl apply -f prometheus-deployment.yml
veeru@ultron:~/prometheus-k8s-monitoring$ kubectl describe svc prometheus-test
Name: prometheus-test
Namespace: default
Labels: name=prometheus-test
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{"prometheus.io/scrape":"true"},"labels":{"name":"prometheus-test"},"name":"prometheus-te...
prometheus.io/scrape=true
Selector: app=prometheus-test
Type: LoadBalancer
IP: 100.xx.xx.xx
LoadBalancer Ingress: xxxxx-1679955855.us-east-2.elb.amazonaws.com
Port: prometheus-test 9090/TCP
TargetPort: 9090/TCP
NodePort: prometheus-test 31558/TCP
Endpoints: 100.xx.xx.xx:9090
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal EnsuringLoadBalancer 9m service-controller Ensuring load balancer
Normal EnsuredLoadBalancer 9m service-controller Ensured load balancer
在上面你可以看到我使用公有DNS名称获得了LoadBalancer Ingress。
kubectl apply -f prometheus-configmap.yml
kubectl apply -f prometheus-rbac.yml
kubectl apply -f prometheus-deployment.yml
root@ultron:/home/veeru/prometheus-k8s-monitoring# oc describe svc prometheus-test
Name: prometheus-test
Namespace: spinnaker
Labels: name=prometheus-test
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{"prometheus.io/scrape":"true"},"labels":{"name":"prometheus-test"},"name":"prometheus-te...
prometheus.io/scrape=true
Selector: app=prometheus-test
Type: LoadBalancer
IP: 172.30.134.153
Port: prometheus-test 9090/TCP
NodePort: prometheus-test 31667/TCP
Endpoints: <none>
Session Affinity: None
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
10m 36s 8 service-controller Normal CreatingLoadBalancer Creating load balancer
10m 36s 8 service-controller Warning CreatingLoadBalancerFailed Error creating load balancer (will retry): Failed to create load balancer for service spinnaker/prometheus-test: could not find any suitable subnets for creating the ELB
您可以看到状态无法为服务创建负载均衡器
如果我指定注释 - &gt; service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
然后我就可以获得&#34;内部&#34;服务的DNS名称
root@ultron:/home/veeru/prometheus-k8s-monitoring# oc describe svc test4-dev
Name: test4-dev
Namespace: default
Labels: <none>
Annotations: service.beta.kubernetes.io/aws-load-balancer-internal=0.0.0.0/0
Selector: load-balancer-test4-dev=true
Type: LoadBalancer
IP: 172.30.177.217
LoadBalancer Ingress: internal-xxxxx-298335522.us-east-2.elb.amazonaws.com
Port: http 8080/TCP
TargetPort: 8080/TCP
NodePort: http 31595/TCP
Endpoints: 10.131.0.75:8080
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal CreatingLoadBalancer 1m (x208 over 16h) service-controller Creating load balancer
Openshift未使用AWS ELB创建公共DNS名称?
答案 0 :(得分:0)
好的,而不是依靠AWS负载均衡器来提供公共DNS名称。我在subdomain
中配置了/etc/openshift/master/master-config.yaml
。
创建A
重新编码(通配符DNS); *.cluster.example.com
- &gt; Your master IP
在/etc/openshift/master/master-config.yaml
routingConfig: subdomain: cluster.example.com serviceAccountConfig
systemctl restart atomic-openshift-master-api atomic-openshift-master-controllers
在此之后你应该能够创建Openshift Route