【问题标题】:istio side car is not createdistio sidecar 未创建
【发布时间】:2020-01-16 14:11:36
【问题描述】:

我们已经安装了 istio,但没有启用侧车,我想在新的命名空间中启用它来特定服务

我已将以下内容添加到我的部署中:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: gow
  labels:
    app: gowspec:
  replicas: 2
  template:
    metadata:
      labels:
        app: gow
        tier: service
      annotations:
        sidecar.istio.io/inject: "true"

在运行时

get namespace -L istio-injection我没有看到任何启用,一切都是空的......

如何验证边车已创建?我没有看到任何新东西...

【问题讨论】:

    标签: kubernetes istio


    【解决方案1】:

    您可以使用istioctl kube-inject 来实现

    kubectl create namespace asdd
    istioctl kube-inject -f nginx.yaml | kubectl apply -f - 
    

    nginx.yaml

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
      namespace: asdd
      labels:
        app: nginx
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          annotations:
            sidecar.istio.io/inject: "True"
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:1.7.9
            ports:
            - containerPort: 80
    

    结果:

    nginx-deployment-55b6fb474b-77788   2/2     Running   0          5m36s
    nginx-deployment-55b6fb474b-jrkqk   2/2     Running   0          5m36s
    

    如果您还有其他问题,请告诉我。

    【讨论】:

    • 感谢这个命令istioctl kube-inject -f nginx.yaml | kubectl apply -f - 我收到错误:Error: error converting YAML to JSON: yaml: line 3: could not find expected ':' 当我只是应用文件并描述它时,我没有看到边车,有什么想法吗?
    • 我按原样使用文件...创建 ns 并使用 istioctl
    • 我正在尝试升级 istioctl 版本
    【解决方案2】:

    您可以描述您的 pod 以查看容器列表,其中之一应该是 sidecar 容器。寻找一个叫做 istio-proxy 的东西。

    kubectl describe pod pod name
    

    它应该如下所示

    $ kubectl describe pod demo-red-pod-8b5df99cc-pgnl7
    SNIPPET from the output:
    
    Name:               demo-red-pod-8b5df99cc-pgnl7
    Namespace:          default
    .....
    Labels:             app=demo-red
                        pod-template-hash=8b5df99cc
                        version=version-red
    Annotations:        sidecar.istio.io/status={"version":"3c0b8d11844e85232bc77ad85365487638ee3134c91edda28def191c086dc23e","initContainers":["istio-init"],"containers":["istio-proxy"],"volumes":["istio-envoy","istio-certs...
    Status:             Running
    IP:                 10.32.0.6
    Controlled By:      ReplicaSet/demo-red-pod-8b5df99cc
    Init Containers:
      istio-init:
        Container ID:  docker://bef731eae1eb3b6c9d926cacb497bb39a7d9796db49cd14a63014fc1a177d95b
        Image:         docker.io/istio/proxy_init:1.0.2
        Image ID:      docker-pullable://docker.io/istio/proxy_init@sha256:e16a0746f46cd45a9f63c27b9e09daff5432e33a2d80c8cc0956d7d63e2f9185
        .....
        State:          Terminated
          Reason:       Completed
        .....
        Ready:          True
    Containers:
      demo-red:
        Container ID:   docker://8cd9957955ff7e534376eb6f28b56462099af6dfb8b9bc37aaf06e516175495e
        Image:          chugtum/blue-green-image:v3
        Image ID:       docker-pullable://docker.io/chugtum/blue-green-image@sha256:274756dbc215a6b2bd089c10de24fcece296f4c940067ac1a9b4aea67cf815db
        State:          Running
          Started:      Sun, 09 Dec 2018 18:12:31 -0800
        Ready:          True
      istio-proxy:
        Container ID:  docker://ca5d690be8cd6557419cc19ec4e76163c14aed2336eaad7ebf17dd46ca188b4a
        Image:         docker.io/istio/proxyv2:1.0.2
        Image ID:      docker-pullable://docker.io/istio/proxyv2@sha256:54e206530ba6ca9b3820254454e01b7592e9f986d27a5640b6c03704b3b68332
        Args:
          proxy
          sidecar
          .....
        State:          Running
          Started:      Sun, 09 Dec 2018 18:12:31 -0800
        Ready:          True
        .....
    

    您需要有 admission webhook 才能自动注入 sidecar。

    kubectl get mutatingwebhookconfiguration istio-sidecar-injector -o yaml | grep "namespaceSelector:" -A5
    

    here 所述,sidecar 注入失败的原因可能有很多

    这是一个table,它显示了基于不同场景的最终注入状态。

    根据上表,必须使用标签istio-injection=enabled 标记命名空间

    kubectl label namespace default istio-injection=enabled --overwrite
    

    【讨论】:

    • 我应该在这个输出中搜索什么?
    • 并且我看到注释在那里(在输出中)但是我没有看到任何新容器,我应该如何验证它创建...?
    • 我没有看到我这边的init容器,我们没有全局启用sidecar,我们想要特定的命名空间和特定的服务来启用它...
    • 除了 init 容器应该还有 istio-proxy
    • 我假设你已经安装了 admission Webhook,因为这会自动注入 sidecar。你在 Kube Api Server 日志中看到任何错误吗?
    猜你喜欢
    • 1970-01-01
    • 2022-11-04
    • 1970-01-01
    • 2020-04-03
    • 2019-03-23
    • 2020-07-10
    • 2019-09-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多