Enable Istio 16/72716/2
authorVictor Morales <victor.morales@intel.com>
Wed, 14 Nov 2018 17:15:36 +0000 (09:15 -0800)
committerVictor Morales <victor.morales@intel.com>
Wed, 14 Nov 2018 17:21:13 +0000 (09:21 -0800)
This commit includes the playbook that installs and configure Istio
Service Mesh services. It also defines a draft script for testing its
sample.

Change-Id: I7f0049aae4ae0033356c370a0e86d583e7bf744f
Signed-off-by: Victor Morales <victor.morales@intel.com>
Issue-ID: MULTICLOUD-406

vagrant/README.md
vagrant/galaxy-requirements.yml
vagrant/inventory/group_vars/k8s-cluster.yml
vagrant/playbooks/configure-istio.yml [new file with mode: 0644]
vagrant/playbooks/krd-vars.yml
vagrant/tests/_functions.sh
vagrant/tests/istio.sh [new file with mode: 0755]

index c76b081..c433a60 100644 (file)
@@ -18,6 +18,7 @@ Virtual Machines.
 | Virtlet        | Allows to run VMs                             | [configure-virtlet.yml][4]        | Tested |
 | Multus         | Provides Multiple Network support in a pod    | [configure-multus.yml][5]         | Tested |
 | NFD            | Node feature discovery                        | [configure-nfd.yml][7]            | Tested |
+| Istio          | Service Mesh platform                         | [configure-istio.yml][8]          | Tested |
 
 ## Deployment
 
@@ -50,3 +51,4 @@ Apache-2.0
 [5]: playbooks/configure-multus.yml
 [6]: https://www.vagrantup.com/
 [7]: playbooks/configure-nfd.yml
+[8]: playbooks/configure-istio.yml
index e3a0fd9..4b25296 100644 (file)
@@ -11,5 +11,7 @@
   version: v2.1.10
 - src: andrewrothstein.kubectl
   version: v1.1.12
+- src: andrewrothstein.kubernetes-helm
+  version: v1.2.9
 - src: geerlingguy.docker
   version: 2.5.1
index c6008de..f038d4f 100644 (file)
@@ -60,8 +60,7 @@ local_volumes_enabled: true
 kube_version: v1.11.3
 
 # Helm deployment
-# NOTE(electrocuracha): This value might be changed for the istio implementation
-helm_enabled: false
+helm_enabled: true
 
 # Kube-proxy proxyMode configuration.
 # NOTE: Ipvs is based on netfilter hook function, but uses hash table as the underlying data structure and
diff --git a/vagrant/playbooks/configure-istio.yml b/vagrant/playbooks/configure-istio.yml
new file mode 100644 (file)
index 0000000..25a343f
--- /dev/null
@@ -0,0 +1,49 @@
+---
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2018
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+- hosts: localhost
+  become: yes
+  pre_tasks:
+    - name: Load krd variables
+      include_vars:
+        file: krd-vars.yml
+  roles:
+    - andrewrothstein.kubectl
+    - role: andrewrothstein.kubernetes-helm
+      kubernetes_helm_ver: v2.9.1
+  tasks:
+    - name: create istio folder
+      file:
+        state: directory
+        path: "{{ istio_dest }}"
+    - name: getting istio CRDs
+      block:
+      - name: download istio tarball
+        get_url:
+          url: "{{ istio_url }}"
+          dest: "/tmp/istio.tar.gz"
+      - name: extract istio source code
+        unarchive:
+          src: "/tmp/istio.tar.gz"
+          dest: "{{ istio_dest }}"
+          remote_src: yes
+      - name: copy istioctl binary to usr/local/bin folder
+        command: "mv {{ istio_dest }}/istio-{{ istio_version }}/bin/istioctl /usr/local/bin/"
+      when: istio_source_type == "tarball"
+    - name: create network objects
+      shell: "/usr/local/bin/kubectl apply -f {{ istio_dest }}/istio-{{ istio_version }}/install/kubernetes/helm/istio/templates/crds.yaml"
+    - name: render istio's core components
+      shell: "/usr/local/bin/helm template {{ istio_dest }}/istio-{{ istio_version }}/install/kubernetes/helm/istio --name istio --namespace istio-system > /tmp/istio.yaml"
+    - name: create istio manifest
+      shell: "/usr/local/bin/kubectl create namespace istio-system"
+      ignore_errors: True
+    - name: install the components via the manifest
+      shell: "/usr/local/bin/kubectl apply -f /tmp/istio.yaml"
+      ignore_errors: True
index b8755a5..9c2de30 100644 (file)
@@ -46,5 +46,10 @@ nfd_source_type: "source"
 nfd_version: 175305b1ad73be7301ac94add475cec6fef797a9
 nfd_url: "https://github.com/kubernetes-incubator/node-feature-discovery"
 
+istio_dest: "{{ base_dest }}/istio"
+istio_source_type: "tarball"
+istio_version: 1.0.3
+istio_url: "https://github.com/istio/istio/releases/download/{{ istio_version }}/istio-{{ istio_version }}-linux.tar.gz"
+
 go_version: 1.11.1
 kubespray_version: 2.7.0
index 515bc6e..c359e72 100755 (executable)
@@ -84,3 +84,4 @@ if ! $(kubectl version &>/dev/null); then
     echo "This funtional test requires kubectl client"
     exit 1
 fi
+test_folder=$(pwd)
diff --git a/vagrant/tests/istio.sh b/vagrant/tests/istio.sh
new file mode 100755 (executable)
index 0000000..79ef4ac
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2018
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+source _functions.sh
+
+csar_id=ac39959e-e82c-11e8-9133-525400912638
+
+base_dest=$(grep "base_dest:" $test_folder/../playbooks/krd-vars.yml | awk -F ': ' '{print $2}')
+istio_dest=$(grep "istio_dest:" $test_folder/../playbooks/krd-vars.yml | awk -F ': ' '{print $2}' | sed "s|{{ base_dest }}|$base_dest|g;s|\"||g")
+istio_version=$(grep "istio_version:" $test_folder/../playbooks/krd-vars.yml | awk -F ': ' '{print $2}')
+
+if ! $(istioctl version &>/dev/null); then
+    echo "This funtional test requires istioctl client"
+    exit 1
+fi
+
+_checks_args $csar_id
+pushd ${CSAR_DIR}/${csar_id}
+istioctl kube-inject -f $istio_dest/istio-$istio_version/samples/bookinfo/platform/kube/bookinfo.yaml > bookinfo-inject.yml
+kubectl apply -f bookinfo-inject.yml
+kubectl apply -f $istio_dest/istio-$istio_version/samples/bookinfo/networking/bookinfo-gateway.yaml
+
+for deployment in details-v1 productpage-v1 ratings-v1 reviews-v1 reviews-v2 reviews-v3; do
+    wait_deployment $deployment
+done
+INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
+INGRESS_HOST=$(kubectl get po -l istio=ingressgateway -n istio-system -o 'jsonpath={.items[0].status.hostIP}')
+curl -o /dev/null -s -w "%{http_code}\n" http://$INGRESS_HOST:$INGRESS_PORT/productpage
+popd