chilcano.istio

Ansible 角色: istio

一个用于在本地运行的 OpenShift 集群中部署 Istio (https://istio.io) 的 Ansible 角色,通常通过使用 Minishift (https://www.openshift.org/minishift) 创建。该角色执行以下任务:

  • 检查本地是否正在运行 OpenShift。
  • 下载并安装指定版本或最新的 Istio。
  • 使用来自 ~/.minishift/cache/oc/<VERSION>/<OS>/ 的最新 oc 二进制文件和下载的 Istio 二进制文件中的 istioctl

前提条件

  • Ansible 2.3+
  • 在运行角色之前,请清除终端会话中的任何 DOCKER* 环境变量。
  • 安装 istioctl 需要在主机上具有 sudo 权限(可选)。
  • 本地运行 OpenShift。有关在虚拟机中运行 OpenShift 的信息,请参阅 https://galaxy.ansible.com/chilcano/minishift

注意事项

Istio Ansible 角色已在以下环境中测试:

  • minishift v1.11.0+4459917
  • kubernetes 3.7
  • istio 0.2.7
  • VirtualBox 5.1.30
  • macOS High Sierra,版本 10.13.2 (17C88)

默认角色变量

默认变量位于 defaults/main.yml 中。

示例剧本

请查看 sample-1-istio.yml 文件以获取示例。

$ cat sample-1-istio.yml
---
- name: 安装 Istio。
  hosts: Pisc0
  connection: local
  gather_facts: yes
  vars:
    vm: openshift0

  roles:
    - role: chilcano.istio
      istio:
        action_to_trigger: clean  # [ deploy | clean ]
        action:
          deploy:
            istioctl: true    # istioctl
            core: true        # 核心组件
            addons: true      # prometheus, graphana, zipkin, servicegraph
            sample_apps: true # bookinfo
        minishift:
          profile: "{{ vm }}"
        openshift:
          project: istio-system    # 默认
          hostname: "{{ vm }}"
          admin_usr: "system:admin"
          admin_pwd: anypassword
          istio_usr: developer
          istio_pwd: anypassword
        repo:
          #release_tag_name: ""   # latest
          release_tag_name: "0.2.7"
          #release_tag_name: "0.2.6"

使用 Ansible 角色

安装角色:

$ sudo ansible-galaxy install chilcano.istio

将剧本从角色路径复制到当前工作目录:

$ cp ${ANSIBLE_ROLES_PATH}/chilcano.istio/sample-1-istio.yml .

创建一个 inventory 文件:

$ echo $(hostname) > ./inventory

运行剧本:

$ ansible-playbook -i inventory --ask-become-pass sample-1-istio.yml

剧本执行完成后,检查所有 Pods、Services 等是否已经部署并运行。

$ eval $(minishift oc-env)

$ oc project bookinfo

$ oc status
在服务器 https://192.168.99.100:8443 的项目 bookinfo 中

svc/details - 172.30.118.151:9080
  pod/details-v1-1464079269-wxfl5 运行 istio/examples-bookinfo-details-v1:0.2.3, docker.io/istio/proxy_debug:0.2.7

svc/productpage - 172.30.163.171:9080
  pod/productpage-v1-3915871613-p2cp6 运行 istio/examples-bookinfo-productpage-v1:0.2.3, docker.io/istio/proxy_debug:0.2.7

svc/ratings - 172.30.13.63:9080
  pod/ratings-v1-327106889-rvqpv 运行 istio/examples-bookinfo-ratings-v1:0.2.3, docker.io/istio/proxy_debug:0.2.7

svc/reviews - 172.30.233.119:9080
  pod/reviews-v1-3806695627-2xkg6 运行 istio/examples-bookinfo-reviews-v1:0.2.3, docker.io/istio/proxy_debug:0.2.7
  pod/reviews-v2-3096629009-2cfht 运行 istio/examples-bookinfo-reviews-v2:0.2.3, docker.io/istio/proxy_debug:0.2.7
  pod/reviews-v3-1994447391-ws74d 运行 istio/examples-bookinfo-reviews-v3:0.2.3, docker.io/istio/proxy_debug:0.2.7

通过 'oc describe <resource>/<name>' 查看详细信息,或通过 'oc get all' 列出所有资源。

$ oc get pods
NAME                              READY     STATUS     RESTARTS   AGE
details-v1-1464079269-wxfl5       0/2       Init:0/2   0          1m
productpage-v1-3915871613-p2cp6   0/2       Init:0/2   0          1m
ratings-v1-327106889-rvqpv        0/2       Init:0/2   0          1m
reviews-v1-3806695627-2xkg6       0/2       Init:0/2   0          1m
reviews-v2-3096629009-2cfht       0/2       Init:0/2   0          1m
reviews-v3-1994447391-ws74d       0/2       Init:0/2   0          1m

$ oc get pods
NAME                              READY     STATUS     RESTARTS   AGE
details-v1-1464079269-wxfl5       0/2       Init:1/2   0          2m
productpage-v1-3915871613-p2cp6   0/2       Init:1/2   0          2m
ratings-v1-327106889-rvqpv        0/2       Init:1/2   0          2m
reviews-v1-3806695627-2xkg6       0/2       Init:1/2   0          2m
reviews-v2-3096629009-2cfht       0/2       Init:1/2   0          2m
reviews-v3-1994447391-ws74d       0/2       Init:1/2   0          2m

$ oc get pods
NAME                              READY     STATUS            RESTARTS   AGE
details-v1-1464079269-wxfl5       0/2       PodInitializing   0          3m
productpage-v1-3915871613-p2cp6   0/2       PodInitializing   0          3m
ratings-v1-327106889-rvqpv        0/2       PodInitializing   0          3m
reviews-v1-3806695627-2xkg6       0/2       PodInitializing   0          3m
reviews-v2-3096629009-2cfht       0/2       PodInitializing   0          3m
reviews-v3-1994447391-ws74d       0/2       PodInitializing   0          3m

$ oc get pods
NAME                              READY     STATUS    RESTARTS   AGE
details-v1-1464079269-wxfl5       2/2       Running   0          7m
productpage-v1-3915871613-p2cp6   2/2       Running   0          7m
ratings-v1-327106889-rvqpv        2/2       Running   0          7m
reviews-v1-3806695627-2xkg6       2/2       Running   0          7m
reviews-v2-3096629009-2cfht       2/2       Running   0          7m
reviews-v3-1994447391-ws74d       2/2       Running   0          7m

最后,你会看到

关于项目

An Ansible Role that installs and configures Istio (https://istio.io) on an OpenShift cluster running locally that has been installed by using Minishift (https://www.openshift.org/minishift).

安装
ansible-galaxy install chilcano.istio
许可证
Unknown
下载
98
拥有者
Crypto, PKI, DevSecOps, Cloud & Cyber Security, SOA, API & Service Mesh.