Update sidecar-injection doc based on 1.9.0-rc.0 (#8896)

* Update sidecar-injection doc based on 1.9.0-rc.0

* Code review comments
This commit is contained in:
jacob-delgado 2021-02-04 08:15:31 -07:00 committed by GitHub
parent 56e128d8df
commit 55f916c51c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 2 deletions

View File

@ -31,6 +31,9 @@ To manually inject a deployment, use [`istioctl kube-inject`](/docs/reference/co
{{< text bash >}}
$ istioctl kube-inject -f @samples/sleep/sleep.yaml@ | kubectl apply -f -
serviceaccount/sleep created
service/sleep created
deployment.apps/sleep created
{{< /text >}}
By default, this will use the in-cluster configuration. Alternatively, injection can be done using local copies of the configuration.
@ -50,6 +53,9 @@ $ istioctl kube-inject \
--valuesFile inject-values.yaml \
--filename @samples/sleep/sleep.yaml@ \
| kubectl apply -f -
serviceaccount/sleep created
service/sleep created
deployment.apps/sleep created
{{< /text >}}
Verify that the sidecar has been injected into the sleep pod with `2/2` under the READY column.
@ -81,7 +87,7 @@ Deploy sleep app. Verify both deployment and pod have a single container.
$ kubectl apply -f @samples/sleep/sleep.yaml@
$ kubectl get deployment -o wide
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
sleep 1/1 1 1 12s sleep governmentpaas/curl-ssl app=sleep
sleep 1/1 1 1 12s sleep curlimages/curl app=sleep
{{< /text >}}
{{< text bash >}}
@ -93,7 +99,7 @@ sleep-8f795f47d-hdcgs 1/1 Running 0 42s
Label the `default` namespace with `istio-injection=enabled`
{{< text bash >}}
$ kubectl label namespace default istio-injection=enabled
$ kubectl label namespace default istio-injection=enabled --overwrite
$ kubectl get namespace -L istio-injection
NAME STATUS AGE ISTIO-INJECTION
default Active 5m9s enabled
@ -119,6 +125,19 @@ View detailed state of the injected pod. You should see the injected `istio-prox
{{< text bash >}}
$ kubectl describe pod -l app=sleep
...
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
...
Normal Created 11s kubelet Created container istio-init
Normal Started 11s kubelet Started container istio-init
...
Normal Created 10s kubelet Created container sleep
Normal Started 10s kubelet Started container sleep
...
Normal Created 9s kubelet Created container istio-proxy
Normal Started 8s kubelet Started container istio-proxy
{{< /text >}}
Disable injection for the `default` namespace and verify new pods are created without the sidecar.
@ -196,6 +215,14 @@ spec:
EOF
{{< /text >}}
It can then be verified that no sidecar was injected.
{{< text bash >}}
$ kubectl get pods -l app=ignored
NAME READY STATUS RESTARTS AGE
ignored-b469d6fcf-8dngz 1/1 Running 0 57s
{{< /text >}}
##### _**template**_
The sidecar injection template uses <https://golang.org/pkg/text/template> which,
@ -311,6 +338,7 @@ It's worth noting that annotations in the pods have higher precedence than the l
{{< text bash >}}
$ kubectl delete mutatingwebhookconfiguration istio-sidecar-injector
mutatingwebhookconfiguration.admissionregistration.k8s.io "istio-sidecar-injector" deleted
{{< /text >}}
The above command will not remove the injected sidecars from Pods. A
@ -322,4 +350,5 @@ were modified in this task.
{{< text bash >}}
$ kubectl label namespace default istio-injection-
namespace/default labeled
{{< /text >}}