LoginSignup
4
6

More than 5 years have passed since last update.

Istio 1.0をオンプレKubernetes上にインストールしてみた

Last updated at Posted at 2018-08-07

サービスメッシュの大本命(?)であるIstioがついに1.0になりましたね
※サービスメッシュに関してはこちらが参考になります。

この記事ではIstio 1.0をGKEなどのパブリッククラウドサービスではなく、ローカルのKubernetes Cluster上にインストールする方法について書きます。

目標

Istio 1.0をKubernetes上にインストールする

前準備

Istioのインストール

  1. Istioのhelm chartを取得

    • vi install-istio.sh
    install-istio.sh
    #! /bin/sh
    OS="$(uname)"
    if [ "x${OS}" = "xDarwin" ] ; then
      OSEXT="osx"
    else
      # TODO we should check more/complain if not likely to work, etc...
      OSEXT="linux"
    fi
    
    if [ "x${ISTIO_VERSION}" = "x" ] ; then
      ISTIO_VERSION=$(curl -L -s https://api.github.com/repos/istio/istio/releases/latest | \
                      grep tag_name | sed "s/ *\"tag_name\": *\"\(.*\)\",*/\1/")
    fi
    
    NAME="istio-$ISTIO_VERSION"
    URL="https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/istio-${ISTIO_VERSION}-${OSEXT}.tar.gz"
    echo "Downloading $NAME from $URL ..."
    curl -L "$URL" | tar xz
    # TODO: change this so the version is in the tgz/directory name (users trying multiple versions)
    echo "Downloaded into $NAME:"
    ls $NAME
    BINDIR="$(cd $NAME/bin; pwd)"
    
    \cp -f $BINDIR/istioctl /usr/local/bin/
    
    • chmod +x install-istio.sh
    • ./install-istio.sh
    • cd istio-1.0.0/install/kubernetes/helm/istio
  2. helm用のvalues.yamlを作成

    • vi myvalues.yaml
      ※とりあえず最低限インストールしています(ご自身で必要なコンポーネントを追加インストールしてください)
    myvalues.yaml
    global:
      controlPlaneSecurityEnabled: true
    
      mtls:
        enabled: true
    
    gateways:
       enabled: true
    
      istio-ingressgateway:
        enabled: true
        type: NodePort
    
      istio-egressgateway:
        enabled: false
    
    ingress:
      enabled: false
    
    prometheus:
      enabled: false
    
    sidecarInjectorWebhook:
      enabled: false
      enableNamespacesByDefault: false
    
    grafana:
      enabled: false
    
    tracing:
      enabled: false
    
    servicegraph:
      enabled: false
    
    galley:
      enabled: false
    
  3. templateの修正
    ISSUEにもありますが、sidecarInjectorWebhookをfalseにすると問題が発生するので、手動で修正します。

    • vi templates/sidecar-injector-configmap.yaml
      ※最初の行({{- if .Values.sidecarInjectorWebhook.enabled }})と最後の行({{ end }})を削除する
  4. install用yamlファイルの作成

    • helm template . --name istio -f myvalues.yaml --namespace istio-system > install-istio.yaml
  5. インストール

    • kubectl create ns istio-system
    • kubectl apply -f install-istio.yaml
  6. サンプルアプリの配備
    詳細は公式ページを参照してください。

    • cd /path/to/istio-install/istio-1.0.0
    • kubectl apply -f <(istioctl kube-inject -f samples/bookinfo/platform/kube/bookinfo.yaml)
    • kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
    • ブラウザでアクセス
    • http://<your-server>:31380/productpage

所感

Istioはどんどん機能が追加されており、v0.8以降オンプレではhelmによるインストールが中心になりました。
v0.7までに比べるとhelmを使う必要があり、少し複雑になりましたが、中の人曰くコンポーネントが増えてきたため仕方ないとのこと。
そのため、今後もhelmによるインストールが中心なのかなぁと思います。
ただローカルKubernetesの場合、helmコマンドで作成したyamlファイルの中もチェックしないと動かないことがあるのでyaml地獄からはなかなか解放されませんねorz
また、Istioは1.0になったとはいえ、ちょっとはまりやすいバグがまだ残っているので根気良く調べる必要はありそうです。(2018年8月現在)

とはいえ、Istioはインストールさえしてしまうととても便利です!
どのサービスとどのサービスをつなげるかを自由に設定できますし、Tracingなんかもサービス単位で簡単に見ることができます。
Microservicesをやるためのノウハウがたまっているので一度触ってみてはいかがでしょうか?

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6