|
| 1 | +# Masher injection |
| 2 | + |
| 3 | +Mesher can be used with any application language on any infrastructure. On Kubernetes, we inject Mesher into Pods, and applications can take advantage of all its features. Below we introduce the use of Mesher injector by example. |
| 4 | + |
| 5 | +## Before |
| 6 | +1. Install Servcicecomb [service-center](http://servicecomb.apache.org/docs/service-center/install/#deployment-with-kubernetes) |
| 7 | + |
| 8 | + |
| 9 | +2. Download the example of quick_start |
| 10 | +```bash |
| 11 | +$ git clone https://github.com/apache/servicecomb-mesher.git |
| 12 | +$ cd ./servicecomb-mesher/examples/quick_start |
| 13 | +``` |
| 14 | + |
| 15 | +3. Build docker images |
| 16 | +```bash |
| 17 | +$ cd ./mesher_injection |
| 18 | +$ bash build_images.sh |
| 19 | +``` |
| 20 | + |
| 21 | +## Automatic Mesher injection |
| 22 | +Meshers can be automatically added to applicable Kubernetes pods using a mutating webhook admission controller provided by Mesher Injector. |
| 23 | + |
| 24 | +1. Create namespace "svccomb-system" |
| 25 | + ```bash |
| 26 | + cp ../../../deployments/kubernetes/injector/*.yaml . |
| 27 | + $ kubectl apply -f svccomb-system.yaml |
| 28 | + namespace/svccomb-system created |
| 29 | + ``` |
| 30 | +2. Generate Injector's certificatesigningrequest and secret |
| 31 | + ```bash |
| 32 | + $ wget https://raw.githubusercontent.com/morvencao/kube-mutating-webhook-tutorial/master/deployment/webhook-create-signed-cert.sh |
| 33 | + |
| 34 | + $ bash webhook-create-signed-cert.sh --service svccomb-mesher-injector --namespace svccomb-system --secret svccomb-mesher-injector-service-account |
| 35 | + ``` |
| 36 | +3. Query caBundle and fill it into "mesher-injector.yaml" |
| 37 | + ```bash |
| 38 | + $ CA_BUNDLE=$(kubectl config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.certificate-authority-data}') |
| 39 | + |
| 40 | + $ sed -i "s|\${CA_BUNDLE}|${CA_BUNDLE}|g" mesher-injector.yaml |
| 41 | + ``` |
| 42 | +4. Deploy mesher injecter |
| 43 | + ```bash |
| 44 | + $ kubectl apply -f mesher-injector.yaml |
| 45 | + mutatingwebhookconfiguration.admissionregistration.k8s.io/svccomb-mesher-injector configured |
| 46 | + service/svccomb-mesher-injector created |
| 47 | + deployment.extensions/svccomb-mesher-injector created |
| 48 | + ``` |
| 49 | +5. Deploy examples to Kubernetes |
| 50 | + ```bash |
| 51 | + $ kubectl apply -f svccomb-test.yaml |
| 52 | + namespace/svccomb-test created |
| 53 | + |
| 54 | + $ kubectl -n svccomb-test apply -f calculator.yaml |
| 55 | + service/calculator created |
| 56 | + deployment.extensions/calculator-python created |
| 57 | + |
| 58 | + $ kubectl -n svccomb-test apply -f webapp.yaml |
| 59 | + service/webapp created |
| 60 | + deployment.extensions/webapp-node created |
| 61 | + ``` |
| 62 | +6. Validated results |
| 63 | + ```bash |
| 64 | + $ kubectl get svc |
| 65 | + NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
| 66 | + calculator ClusterIP 10.104.2.143 <none> 5000/TCP 3m43s |
| 67 | + kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 42d |
| 68 | + webapp NodePort 10.104.134.148 <none> 5001:30062/TCP 3m35s |
| 69 | + ``` |
| 70 | + Open the page "http://127.0.0.1:30062" in your browser, enter your height and weight in the input boxes, and click the submit button, you can see the BMI results about you. |
0 commit comments