LoginSignup
1
1

More than 3 years have passed since last update.

Alibaba CloudのKubernetesサービスをVisual Studio Codeから利用する

Last updated at Posted at 2019-05-24

はじめに

Alibaba Cloud の kubernetes サービス(Alibaba Cloud Container Service for Kubernetes (ACK))をVS Codeで触ってみました。
Visual Studio Code に Visual Studio Code Kubernetes Toolsを入れて利用します。

ちなみにkubectlコマンドとdockerコマンドを使うのでそれぞれインストールが必要になります。
すでに入っている場合が多いと思いますが😅

Install kubectl
Install Docker

Visual Studio Code Kubernetes Tools のインストール

拡張機能は此方のmarketplaceからインストール

image.png

又はVS Codeの拡張機能から選択

image.png

インストール完了するとkubernetesのアイコンがあるので選択するとclusterの設定やHelmのRepositoryが見える様になると思います。
※kubeconfig の設定が終わってる前提です。

設定が終わってない場合はKubernetes: Set Kubeconfigで設定が必要です。

image.png

もしくは画面の下記の部分から設定しましょう。
image.png

下記の画面で作成済みのkubeconfigファイルを指定する事で設定を読み込みます。
image.png

なおCLUSTERSの部分はkubectl config get-contextsで見えるコンテキストが表示されてます。
image.png

複数のクラスターを管理している場合は「▶︎」が付いているクラスターがCurrentです。
別のクラスターに切り替えたい場合は対象のクラスターを右クリックして表示されるメニューでSet as Current Clusterを選択してください。

image.png

「▶︎」が切り替わります。
image.png

クラスターの中を見ていくといろんな情報が取れます。
編集も可能です。
image.png

Deployment

では適当にデプロイしてみたいと思います。
image.png

マニフェストを書いたらコマンドパレットからKubernetes: Createを選択します。
image.png

メッセージが出るので確認してください。
Createdであれば成功しているはずです。
image.png

Deploymentsのなかにtestappが無事に作成されました❗️

image.png

ちなみにAlibaba Cloudのコンソールからだとこんな感じです。
ちゃんと反映されてますね😁
image.png

Service

ここもyaml書いてもいいのですが、面倒なので今回はコマンドで作ります。
kubectl expose deployment testapp --port=8080 --target-port=8080 --type=LoadBalancer

testappというServiceが出来ます。
image.png

対象のServiceを選択しGetをクリックすると。Serviceの情報が取得できます。
image.png

Alibaba Cloudのコンソールを見に行くとSLB(Load balancerのサービス)のインスタンスが作られています。
image.png

実際にIPにアクセスするとTomcatの画面がちゃんと表示されます!
image.png

Dashboard

Open Dashboardを選択してみます。
image.png

何かがlocalhostで起動する様です。
image.png

Dashboardを入れていればこれでアクセス出来るはずですが、Alibaba Cloud Kubernetes サービスはコンソール上での独自ダッシュボードが提供されているので、デフォルトだと表示されませんね。
http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

image.png

ちなみにAlibaba Cloudのコンソールからだとこんな感じの画面がでるよ。
image.png

設定系のコマンドパレット

Kubernetes: Add Existing Cluster
Install and configure the Kubernetes command line tool (kubectl) from a cloud cluster, such as an Azure Container Service (ACS) or Azure Kubernetes Service (AKS) cluster

Kubernetes: Set as Current Cluster
Select from a list of configured clusters to set the "current" cluster. Used for searching, displaying, and deploying Kubernetes resources.

Kubernetes: Delete Context
Remove a cluster's configuration from the kubeconfig file.

Kubernetes: Set Kubeconfig
Select from a list of known kubeconfig files (for users who keep different kubeconfig files for different environments).

Kubernetes: Show Cluster Info
For a cluster, show the status of Kubernetes Components (API Server, etcd, KubeDNS, etc.) in a terminal window.

Kubernetes: Use Namespace
Select from a list of namespaces to set the "current" namespace. Used for searching, displaying, and deploying Kubernetes resources.

おわりに

ただ単にVisual Studio Code が好き・・・というか使いやすいのでVSCodeで完結したいなと思いやってみましたー

雑ですが参考になれば幸いです。

1
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
1
1