はじめに
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からインストール
又はVS Code
の拡張機能から選択
インストール完了するとkubernetesのアイコンがあるので選択するとclusterの設定やHelmのRepositoryが見える様になると思います。
※kubeconfig の設定が終わってる前提です。
設定が終わってない場合はKubernetes: Set Kubeconfig
で設定が必要です。
下記の画面で作成済みのkubeconfig
ファイルを指定する事で設定を読み込みます。
なおCLUSTERS
の部分はkubectl config get-contexts
で見えるコンテキストが表示されてます。
複数のクラスターを管理している場合は「▶︎」が付いているクラスターがCurrentです。
別のクラスターに切り替えたい場合は対象のクラスターを右クリックして表示されるメニューでSet as Current Cluster
を選択してください。
クラスターの中を見ていくといろんな情報が取れます。
編集も可能です。
Deployment
マニフェストを書いたらコマンドパレットからKubernetes: Create
を選択します。
メッセージが出るので確認してください。
Created
であれば成功しているはずです。
Deployments
のなかにtestapp
が無事に作成されました❗️
ちなみにAlibaba Cloudのコンソールからだとこんな感じです。
ちゃんと反映されてますね😁
Service
ここもyaml書いてもいいのですが、面倒なので今回はコマンドで作ります。
kubectl expose deployment testapp --port=8080 --target-port=8080 --type=LoadBalancer
対象のServiceを選択しGet
をクリックすると。Serviceの情報が取得できます。
Alibaba Cloudのコンソールを見に行くとSLB(Load balancerのサービス)のインスタンスが作られています。
実際にIPにアクセスするとTomcatの画面がちゃんと表示されます!
Dashboard
Dashboardを入れていればこれでアクセス出来るはずですが、Alibaba Cloud Kubernetes サービスはコンソール上での独自ダッシュボードが提供されているので、デフォルトだと表示されませんね。
http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
ちなみにAlibaba Cloudのコンソールからだとこんな感じの画面がでるよ。
設定系のコマンドパレット
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で完結したいなと思いやってみましたー
雑ですが参考になれば幸いです。