在yaml中,我应该设置”HostNetwork: true”在哪里?

huangapple go评论53阅读模式
英文:

Where in the yaml do I set "HostNetwork: true"?

问题

我找到了一篇帖子建议我在我的bind9-deployment.yaml文件的spec:部分中使用

HostNetwork: true

但我不确定它应该放在文件的哪个部分:

kind: Service

还是

kind: Deployment

我希望最终将我的本地bind9服务提供给我的本地网络。

英文:

I found one post that suggested I use

HostNetwork: true

in the spec: section on my bind9-deployment.yaml file but I'm not sure whether it goes in the spec: under

kind: Service

or

kind: Deployment 

section of my file.

I am hoping eventually to make my on-prem bind9 service available to my local network.

答案1

得分: 0

请参考这里了解在使用 hostNetwork 时有关 DNS 策略的更多信息。

version: v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      container:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
英文:

See here for more info about DNS policy when using hostNetwork.

version: v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      container:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80

huangapple
  • 本文由 发表于 2023年1月9日 08:32:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75052268.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定