在需要第一个服务的 IP 地址的地方部署服务
deployment of services where one needs IP address of first service
我创建了两个服务。
myymlservice
mysql-部署
myymlservice 需要 mysql-deployment 的负载均衡器的 IP 地址(因此它可以为其创建连接字符串)
minikube service list
|-------------|----------------------|--------------------------------|
| NAMESPACE | NAME | URL |
|-------------|----------------------|--------------------------------|
| default | kubernetes | No node port |
| default | mysql-deployment | http://192.168.99.100:30928 |
| default | myymlservice | http://192.168.99.100:32724 |
| | | http://192.168.99.100:31461 |
| kube-system | kube-dns | No node port |
| kube-system | kubernetes-dashboard | No node port |
|-------------|----------------------|--------------------------------|
..
kubectl describe service mysql-deployment
Name: mysql-deployment
Namespace: default
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"mysql-deployment","namespace":"default"},"spec":{"ports":[{"port":1433,"protoc...
Selector: app=mysql
Type: LoadBalancer
IP: 10.107.53.255
Port: <unset> 1433/TCP
TargetPort: 1433/TCP
NodePort: <unset> 30928/TCP
Endpoints: 172.17.0.7:1433
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
一项服务(或支持该服务的容器)如何(使用 yml)获取 IP 地址?
我在上一个问题中的更多设置:
如果要构建连接字符串,可以使用服务名称而不是 ip。例如 mysql-deployment.default.svc.cluster.local。那是因为 kubernetes 有一个 "dns" built-in and dns resolution
我创建了两个服务。
myymlservice
mysql-部署
myymlservice 需要 mysql-deployment 的负载均衡器的 IP 地址(因此它可以为其创建连接字符串)
minikube service list
|-------------|----------------------|--------------------------------|
| NAMESPACE | NAME | URL |
|-------------|----------------------|--------------------------------|
| default | kubernetes | No node port |
| default | mysql-deployment | http://192.168.99.100:30928 |
| default | myymlservice | http://192.168.99.100:32724 |
| | | http://192.168.99.100:31461 |
| kube-system | kube-dns | No node port |
| kube-system | kubernetes-dashboard | No node port |
|-------------|----------------------|--------------------------------|
..
kubectl describe service mysql-deployment
Name: mysql-deployment
Namespace: default
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"mysql-deployment","namespace":"default"},"spec":{"ports":[{"port":1433,"protoc...
Selector: app=mysql
Type: LoadBalancer
IP: 10.107.53.255
Port: <unset> 1433/TCP
TargetPort: 1433/TCP
NodePort: <unset> 30928/TCP
Endpoints: 172.17.0.7:1433
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
一项服务(或支持该服务的容器)如何(使用 yml)获取 IP 地址?
我在上一个问题中的更多设置:
如果要构建连接字符串,可以使用服务名称而不是 ip。例如 mysql-deployment.default.svc.cluster.local。那是因为 kubernetes 有一个 "dns" built-in and dns resolution