2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Windows Subsystem for Linux (WSL) にAzure CLIとkubectl を入れる

Last updated at Posted at 2019-04-26

概要

  • AzureでKubernetesを動かす準備をする
  • WindowsのPCにWindows Subsystem for Linux(WSL)にUbuntu 18.04 を入れる
  • UbuntuにAzure CLIとkubectlを入れ、azコマンドでkubectlを使えるようにする

参考書籍

Windows Subsystem for Linux(WSL)にUbuntu 18.04 を入れる

  • 「Windowsの機能の有効化または無効化」で、「Windows Subsystem for Linux」を有効化(PCの再起動が必要)
  • 「Microsoft Store」(アプリ)を起動
  • 検索ボックスで「ubuntu 18.04」を検索して入れる
  • スタートメニューから起動
  • Ctrl + Shift + Cでコピペできるように、プロパティで「Ctrl+Shift+C/Vをコピー/貼り付けとして使用する」にチェックを入れる
  • アップデートとか
    • sudo apt update
    • sudo apt dist-upgrade
    • sudo apt autoremove

Azure CLI のインストール

apt での Azure CLI のインストール」を見ながら、インストールする

  • 必要なパッケージを取得
sudo apt-get update
sudo apt-get install curl apt-transport-https lsb-release gpg
  • Microsoft の署名キーをダウンロードしてインストール
curl -sL https://packages.microsoft.com/keys/microsoft.asc | \
    gpg --dearmor | \
    sudo tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg > /dev/null
  • Azure CLI ソフトウェア リポジトリを追加
AZ_REPO=$(lsb_release -cs)

echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | \
    sudo tee /etc/apt/sources.list.d/azure-cli.list
  • リポジトリ情報を更新し、azure-cli パッケージをインストール
sudo apt-get update
sudo apt-get install -y build-essential libssl-dev libffi-dev python-dev
sudo apt-get install azure-cli

(なぜか「Unpacking azure-cli (2.0.63-1~bionic) ...」で30分待ってもディスクアクセスしっぱなしだったので、途中で止めてbuild-essential libssl-dev libffi-dev python-devを入れました)

参考:Installation of azure-cli 'hangs' on unpacking #2775

Azure へのログイン

az login

ブラウザが開くので、ログインします。

Azure CLIの初期設定

  • az configure で、出力形式を「3: table」にしておく。
  • リソースプロバイダを有効にする
    • az provider register -n Microsoft.Network
    • az provider register -n Microsoft.Storage
    • az provider register -n Microsoft.Compute
    • az provider register -n Microsoft.ContainerService

kubectl のインストール

sudo apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo touch /etc/apt/sources.list.d/kubernetes.list
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl

kubectl version でバージョン確認。

azコマンドでkubectlを使えるようにする

sudo az aks install-cli
2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?