- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在关注 Kubernetes 教程:https://kubernetes.io/docs/tutorials/stateless-application/guestbook/#creating-the-redis-master-service
但是有一条线我不明白。在前端部署中有 GET_HOSTS_FROM 变量。它的值为“dns”。是进一步评估还是保留为“dns”?
这是整个对应的yaml:
#application/guestbook/frontend-deployment.yaml
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: frontend
labels:
app: guestbook
spec:
selector:
matchLabels:
app: guestbook
tier: frontend
replicas: 3
template:
metadata:
labels:
app: guestbook
tier: frontend
spec:
containers:
- name: php-redis
image: gcr.io/google-samples/gb-frontend:v4
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: GET_HOSTS_FROM
value: dns
# Using `GET_HOSTS_FROM=dns` requires your cluster to
# provide a dns service. As of Kubernetes 1.3, DNS is a built-in
# service launched automatically. However, if the cluster you are using
# does not have a built-in DNS service, you can instead
# access an environment variable to find the master
# service's host. To do so, comment out the 'value: dns' line above, and
# uncomment the line below:
# value: env
ports:
- containerPort: 80
最佳答案
GET_HOSTS_FROM
的值不会被进一步评估 - 它仍然是“dns”。
查看应用程序的源代码 here , GET_HOSTS_FROM
用于确定 Redis 主从主机是否来自环境,或者默认情况下是 primary 的 Kubernetes 服务名称和 slave :
$host = 'redis-master';
if (getenv('GET_HOSTS_FROM') == 'env') {
$host = getenv('REDIS_MASTER_SERVICE_HOST');
}
当主机名是 Kubernetes 服务名时,它们将使用集群的 DNS 进行解析.
值得一提的是 pod 可以如何引用相同命名空间和不同命名空间中的服务(摘录自上面给出的文档的链接):
...if you have a Service called "my-service" in a Kubernetes Namespace "my-ns", the control plane and the DNS Service acting together create a DNS record for "my-service.my-ns". Pods in the "my-ns" Namespace should be able to find it by simply doing a name lookup for my-service ("my-service.my-ns" would also work).
关于kubernetes - GET_HOSTS_FROM 变量的值是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58733807/
我正在关注 Kubernetes 教程:https://kubernetes.io/docs/tutorials/stateless-application/guestbook/#creating-t
我是一名优秀的程序员,十分优秀!