Search code examples
kuberneteskubernetes-helmistio

Helm skips creation of istio virtual service


I am trying to create a helm chart for my service with the following structure:

.
├── my-app
│   ├── Chart.yaml
│   ├── templates
│   │   ├── deployment.yaml
│   │   ├── istio-virtualservice.yaml
│   │   └── service.yaml
│   └── values.yaml

After installing the helm chart the deployment and service are being created successfully but the virtualservice is not being created.

$ helm install -name my-app ./my-app -n my-namespace
$ kubectl get pods -n my-namespace
NAME                              READY   STATUS    RESTARTS   AGE
my-app-5578cbb95-xzqzk            2/2     Running   0          5m

$ kubectl get vs
NAME                 GATEWAYS               HOSTS                         AGE
<Empty>

My istio virtual service yaml files looks like:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-virtual-service
spec:
  hosts:
    - {{$.Values.props.host | quote}}
  gateways:
    - my-api-gateway
  http:
    - match:
        - uri:
            prefix: /app/
      rewrite:
        uri: "/"
      route:
        - destination:
            port:
              number: 8083
            host: my-service.my-namespace.svc.cluster.local

Surprisingly, if i apply the above yaml after helm install is done deploying the app then the virtualservice gets created.

$ kubectl apply -f istio-vs.yaml
$ kubectl get vs
NAME                 GATEWAYS               HOSTS                         AGE
my-virtual-service   [my-api-gateway]   [my-host.com]                     60s

Please help me debug the issue and let me know if more debug information is needed.

$ helm version
version.BuildInfo{Version:"v3.0.1", GitCommit:"7c22ef9ce89e0ebeb7125ba2ebf7d421f3e82ffa", GitTreeState:"clean", GoVersion:"go1.13.4"}
$ istioctl version
client version: 1.4.1
control plane version: 1.4.1
data plane version: 1.4.1 (2 proxies)
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"16+", GitVersion:"v1.16.6-beta.0", GitCommit:"e7f962ba86f4ce7033828210ca3556393c377bcc", GitTreeState:"clean", BuildDate:"2020-01-15T08:26:26Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"16+", GitVersion:"v1.16.6-beta.0", GitCommit:"e7f962ba86f4ce7033828210ca3556393c377bcc", GitTreeState:"clean", BuildDate:"2020-01-15T08:18:29Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"linux/amd64"}

Solution

  • Use

    kubectl get vs -n my-namespace
    

    instead of

    kubectl get vs
    

    That´s because you have deployed everything in the my-namespace namespace.

    helm install -name my-app ./my-app -n my-namespace

    And you´re searching for virtual service in the default namespace.


    It´s working when you apply it by yourself, because there is no namespace in the virtual service yaml and it´s deployed in the default one.


    Additional info, I see you have gateway which is already deployed, if it´s not in the same namespace as virtual service, you should add it like in below example.

    Check the spec.gateways section

    apiVersion: networking.istio.io/v1alpha3
    kind: VirtualService
    metadata:
      name: bookinfo-Mongo
      namespace: bookinfo-namespace
    spec:
      gateways:
      - some-config-namespace/my-gateway # can omit the namespace if gateway is in same
                                           namespace as virtual service.
    

    I hope this answer your question. Let me know if you have any more questions.