|
| 1 | +# Up and running manually on Docker for desktop and AKS |
| 2 | + |
| 3 | +## Docker for desktop |
| 4 | + |
| 5 | +### Step 1 |
| 6 | + |
| 7 | +Make sure we have **`Docker for Desktop`** running with **`Kubernetes`** option enabled. We need to install **`kubectl`**, **`helm`** and **`istioctl`** on the build machine as well. |
| 8 | + |
| 9 | +### Step 2 |
| 10 | + |
| 11 | +From current console, type `bash` to enter `Linux Subsystem (Ubuntu)` |
| 12 | + |
| 13 | +### Step 3 |
| 14 | + |
| 15 | +Then `cd` into your root of project |
| 16 | + |
| 17 | +``` |
| 18 | +> ./deploys/scripts/build-all-images.sh |
| 19 | +``` |
| 20 | + |
| 21 | +It should run and package all docker images. |
| 22 | + |
| 23 | +### Step 4 |
| 24 | + |
| 25 | +Download and install [istio-1.0.0](https://github.com/istio/istio/releases/tag/1.0.0) on the box, and unzip it into somewhere, then initialize it with following commands |
| 26 | + |
| 27 | +``` |
| 28 | +> cd <istio-1.0.0 path> |
| 29 | +> kubectl create -f install/kubernetes/helm/helm-service-account.yaml |
| 30 | +> helm init --service-account tiller --upgrade |
| 31 | +> helm install install/kubernetes/helm/istio --name istio --namespace istio-system |
| 32 | +``` |
| 33 | + |
| 34 | +More information about installing `istio` can be found at https://istio.io/docs/setup/kubernetes/helm-install |
| 35 | + |
| 36 | +### Step 5 |
| 37 | + |
| 38 | +Apply `istioctl` command to `coolstore` chart (please create k8s folder in folder deploys) |
| 39 | + |
| 40 | +``` |
| 41 | +> helm template deploys/charts/coolstore -f deploys/charts/coolstore/values.dev.yaml > deploys/k8s/coolstore.local.yaml |
| 42 | +> istioctl kube-inject -f deploys/k8s/coolstore.local.yaml | kubectl apply -f - |
| 43 | +``` |
| 44 | + |
| 45 | +### Step 6 |
| 46 | + |
| 47 | +Add hosts file with following content |
| 48 | + |
| 49 | +``` |
| 50 | +127.0.0.1 api.coolstore.local |
| 51 | +127.0.0.1 id.coolstore.local |
| 52 | +127.0.0.1 coolstore.local |
| 53 | +``` |
| 54 | + |
| 55 | +Waiting for the container provision completed |
| 56 | + |
| 57 | +### Step 7 |
| 58 | + |
| 59 | +Install `coolstore-istio` chart |
| 60 | + |
| 61 | +``` |
| 62 | +> helm install deploys\charts\coolstore-istio --name coolstore-istio |
| 63 | +``` |
| 64 | + |
| 65 | +### Step 8 |
| 66 | + |
| 67 | +Access to following URLs |
| 68 | + |
| 69 | +``` |
| 70 | +> curl -I http://coolstore.local # website |
| 71 | +> curl -I http://api.coolstore.local # api gateway |
| 72 | +> curl -I http://id.coolstore.local # identity provider |
| 73 | +``` |
| 74 | + |
| 75 | +### Step 9 |
| 76 | + |
| 77 | +Clean up `coolstore` chart as |
| 78 | + |
| 79 | +``` |
| 80 | +> kubectl delete -f deployment/istio/coolstore.local.yaml |
| 81 | +> helm delete coolstore-istio --purge |
| 82 | +> helm delete istio --purge |
| 83 | +``` |
| 84 | + |
| 85 | +**_Notes_**: |
| 86 | + |
| 87 | +- Global path: set `PATH` for `docker`, `kubectl`, `helm`, and `istioctl`. |
| 88 | + |
| 89 | +- Run with Nginx (not recommendation): if you want to run just only `Kubernetes` + `nginx-ingress` go to `deploys/charts/coolstore/values.yaml`, and modify as following |
| 90 | + |
| 91 | + ```bash |
| 92 | + nginx: |
| 93 | + enabled: true |
| 94 | + ``` |
| 95 | + |
| 96 | + Then run the `helm` command as |
| 97 | + |
| 98 | + ```bash |
| 99 | + helm install --name cs-nginx stable/nginx-ingress |
| 100 | + ``` |
| 101 | + |
| 102 | +## Azure Kubernetes Service (AKS) |
| 103 | + |
| 104 | +### Step 1: Install Docker for Windows and enable Kubernetes, Ubuntu WSL, kubectl, istioctl, helm and az |
| 105 | + |
| 106 | +### Step 2: Create coolstore AKS, enabled RBAC. Minimum should have 3 nodes (istio pilot needs it) |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | +And make sure checking to `enable RBAC` as following |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | +Follow up with next steps to finish creating the cluster. It normally takes around `20 to 30 minutes`. |
| 115 | + |
| 116 | +After it finished, we should be able to access to the `Kubernetes Dashboard` with following steps |
| 117 | + |
| 118 | +```bash |
| 119 | +$ az aks get-credentials --resource-group coolstore --name coolstore |
| 120 | +$ kubectl proxy |
| 121 | +``` |
| 122 | + |
| 123 | +But now, you will not be able to access to Kubernetes Dashboard. Then we need to add several steps then |
| 124 | + |
| 125 | +```bash |
| 126 | +$ kubectl create clusterrolebinding kubernetes-dashboard -n kube-system --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard |
| 127 | +``` |
| 128 | + |
| 129 | +Get the `token` subsequently |
| 130 | + |
| 131 | +```bash |
| 132 | +$ kubectl get secret \$(kubectl get serviceaccount kubernetes-dashboard -n kube-system -o jsonpath="{.secrets[0].name}") -n kube-system -o jsonpath="{.data.token}" | base64 --decode |
| 133 | +``` |
| 134 | + |
| 135 | +Paste the token to login page as http://localhost:8001/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy/#!/login |
| 136 | + |
| 137 | +### Step 3: Install Istio on AKS |
| 138 | + |
| 139 | +Due to some of the timeout issues for helm at now so that I couldn’t use helm to install, but `export` it to yaml file, then using kubectl to create it on AKS. `Download istio 1.0.0`, then upzip to somewhere on the machine. Following command to export and deploy it to AKS |
| 140 | + |
| 141 | +```bash |
| 142 | +$ helm template install/kubernetes/helm/istio --namespace istio-system > istio-dump.yaml |
| 143 | +$ kubectl create -f istio-dump.yaml |
| 144 | +$ kubectl create -f istio-dump.yaml |
| 145 | +``` |
| 146 | + |
| 147 | +### Step 4: Install Coolstore on AKS |
| 148 | + |
| 149 | +Get the `internal istio-ingress IP` by using |
| 150 | + |
| 151 | +```bash |
| 152 | +$ kubectl get services istio-ingressgateway -n istio-system -o=jsonpath={.spec.clusterIP} |
| 153 | +``` |
| 154 | + |
| 155 | +Create the `values.aks.yaml` with content like |
| 156 | + |
| 157 | +gateway: |
| 158 | +ip: 10.0.106.82 |
| 159 | + |
| 160 | +Then run helm command |
| 161 | + |
| 162 | +```bash |
| 163 | +> helm template deploys/charts/coolstore -f deploys/charts/coolstore/values.aks.yaml > deploys/k8s/dev-all-in-one.aks.yaml |
| 164 | +``` |
| 165 | + |
| 166 | +Finally, we `inject sidecar` with this command |
| 167 | + |
| 168 | +```bash |
| 169 | +$ istioctl kube-inject -f deploys/k8s/dev-all-in-one.aks.yaml | kubectl apply -f - |
| 170 | +``` |
| 171 | + |
| 172 | +### Step 5: Put mapping for hosts file |
| 173 | + |
| 174 | +Get `external IP` on istio ingress by using |
| 175 | + |
| 176 | +```bash |
| 177 | +$ kubectl get svc -n istio-system |
| 178 | +``` |
| 179 | + |
| 180 | +It should print out something like |
| 181 | + |
| 182 | +```bash |
| 183 | +... |
| 184 | +istio-ingressgateway LoadBalancer 10.106.52.19 localhost 80:31380/TCP,443:31390/TCP,31400:31400/TCP,15011:32131/TCP,8060:30958/TCP,15030:31983/TCP,15031:30365/TCP 8d |
| 185 | +... |
| 186 | +``` |
| 187 | + |
| 188 | +Then, we only need to copy `10.106.52.19` to `C:\Windows\System32\drivers\etc\hosts` file as following |
| 189 | + |
| 190 | +```bash |
| 191 | +10.106.52.19 id.coolstore.aks |
| 192 | +10.106.52.19 api.coolstore.aks |
| 193 | +10.106.52.19 coolstore.aks |
| 194 | +``` |
| 195 | + |
| 196 | +From now on, we can access website at `http://coolstore.aks`, identity provider at `http://id.coolstore.aks`, and api gateway at `http://api.coolstore.aks` |
| 197 | + |
| 198 | +Let say we access to `http://api.coolstore.aks/cart/swagger`, then we should see |
| 199 | + |
| 200 | + |
| 201 | + |
| 202 | +And the website at `http://coolstore.aks` |
| 203 | + |
| 204 | +More information at https://hackernoon.com/5-steps-to-bring-coolstores-service-mesh-to-azure-kubernetes-service-aks-9cd1a5aa008a |
0 commit comments