|
| 1 | +# Securing application communication with knative |
| 2 | + |
| 3 | +# Installing knative |
| 4 | + |
| 5 | +To install knative run the following |
| 6 | + |
| 7 | +### minikube |
| 8 | +``` |
| 9 | +curl -L https://raw.githubusercontent.com/knative/serving/v0.2.0/third_party/istio-1.0.2/istio.yaml \ |
| 10 | + | sed 's/LoadBalancer/NodePort/' \ |
| 11 | + | kubectl apply --filename - |
| 12 | +kubectl label namespace default istio-injection=enabled |
| 13 | +curl -L https://github.com/knative/serving/releases/download/v0.2.0/release-lite.yaml \ |
| 14 | + | sed 's/LoadBalancer/NodePort/' \ |
| 15 | + | kubectl apply --filename - |
| 16 | +``` |
| 17 | + |
| 18 | +### Play with kubernetes |
| 19 | +``` |
| 20 | +kubectl apply --filename https://raw.githubusercontent.com/knative/serving/v0.2.2/third_party/istio-1.0.2/istio.yaml |
| 21 | +kubectl label namespace default istio-injection=enabled |
| 22 | +kubectl apply --filename https://github.com/knative/serving/releases/download/v0.2.2/release.yaml |
| 23 | +``` |
| 24 | + |
| 25 | +# Configuring outbound network access |
| 26 | + |
| 27 | +Knative blocks all outbound traffic by default. To enable outbound access (when you want to connect |
| 28 | +to the Cloud Storage API, for example), you need to change the scope of the proxy IP range by editing |
| 29 | +the `config-network` map. |
| 30 | + |
| 31 | +## Determining the IP scope of your cluster |
| 32 | + |
| 33 | +To set the correct scope, you need to determine the IP ranges of your cluster. The scope varies |
| 34 | +depending on your platform: |
| 35 | + |
| 36 | +* For Minikube use `10.0.0.1/24` |
| 37 | + |
| 38 | +## Setting the IP scope |
| 39 | + |
| 40 | +The `istio.sidecar.includeOutboundIPRanges` parameter in the `config-network` map specifies |
| 41 | +the IP ranges that Istio sidecar intercepts. To allow outbound access, replace the default parameter |
| 42 | +value with the IP ranges of your cluster. |
| 43 | + |
| 44 | +Run the following command to edit the `config-network` map: |
| 45 | + |
| 46 | +```shell |
| 47 | +kubectl edit configmap config-network --namespace knative-serving |
| 48 | +``` |
| 49 | + |
| 50 | +Then, use an editor of your choice to change the `istio.sidecar.includeOutboundIPRanges` parameter value |
| 51 | +from `*` to the IP range you need. Separate multiple IP entries with a comma. For example: |
| 52 | + |
| 53 | +``` |
| 54 | +# Please edit the object below. Lines beginning with a '#' will be ignored, |
| 55 | +# and an empty file will abort the edit. If an error occurs while saving this file will be |
| 56 | +# reopened with the relevant failures. |
| 57 | +# |
| 58 | +apiVersion: v1 |
| 59 | +data: |
| 60 | + istio.sidecar.includeOutboundIPRanges: '10.16.0.0/14,10.19.240.0/20' |
| 61 | +kind: ConfigMap |
| 62 | +metadata: |
| 63 | + ... |
| 64 | +``` |
| 65 | + |
| 66 | +By default, the `istio.sidecar.includeOutboundIPRanges` parameter is set to `*`, |
| 67 | +which means that Istio intercepts all traffic within the cluster as well as all traffic that is going |
| 68 | +outside the cluster. Istio blocks all traffic that is going outside the cluster unless |
| 69 | +you create the necessary egress rules. |
| 70 | + |
| 71 | +When you set the parameter to a valid set of IP address ranges, Istio will no longer intercept |
| 72 | +traffic that is going to the IP addresses outside the provided ranges, and you don't need to specify |
| 73 | +any egress rules. |
| 74 | + |
| 75 | +If you omit the parameter or set it to `''`, Knative uses the value of the `global.proxy.includeIPRanges` |
| 76 | +parameter that is provided at Istio deployment time. In the default Knative Serving |
| 77 | +deployment, `global.proxy.includeIPRanges` value is set to `*`. |
| 78 | + |
| 79 | +If an invalid value is passed, `''` is used instead. |
| 80 | + |
| 81 | +If you are still having trouble making off-cluster calls, you can verify that the policy was |
| 82 | +applied to the pod running your service by checking the metadata on the pod. |
| 83 | +Verify that the `traffic.sidecar.istio.io/includeOutboundIPRanges` annotation matches the |
| 84 | +expected value from the config-map. |
| 85 | + |
| 86 | +```shell |
| 87 | +$ kubectl get pod ${POD_NAME} --output yaml |
| 88 | + |
| 89 | +apiVersion: v1 |
| 90 | +kind: Pod |
| 91 | +metadata: |
| 92 | + annotations: |
| 93 | + serving.knative.dev/configurationGeneration: "2" |
| 94 | + sidecar.istio.io/inject: "true" |
| 95 | + ... |
| 96 | + traffic.sidecar.istio.io/includeOutboundIPRanges: 10.16.0.0/14,10.19.240.0/20 |
| 97 | +... |
0 commit comments