LoginSignup
1
1

Kubernetes超入門 part2 Rancherの導入

Posted at

前回、kubernetes超入門でクラスタを構築しました。

それではkubernetesを使いやすくするために、rancherというGUIを入れてみましょう。

helmのインストール

helmというのはKubernetesのパッケージマネージャーです。いい感じにデプロイしてくれます。
公式HPの通りで良いですが、下記になります。

別にkubernetes外のPCから操作してもいいのですが、ひとまず前回サーバーにした1台で下記実行していきます。

curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
helm version

これでOK。

次にrancherのhelmチャートを追加します。

helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
kubectl create namespace cattle-system
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/<VERSION>/cert-manager.crds.yaml
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --create-namespace

もしここでunreachable localhost:8080とかになったときは、helmがkuberenetesのURLをうまく叩けていません。~/.kube/configがあるか、ちゃんと正しいサーバーURLか、全サーバーにその設定が入っているか、など確認してみてください。

あとはhelmでインストールするだけです。

helm install rancher rancher-latest/rancher --namespace cattle-system --set hostname=rancher.your.host --set replicas=1 --set bootstrapPassword=super_strong_password

で、ここのhostnameなんですがhostsで設定しておくと良いと思います。
同じネットワーク内にWindowsとかMacとかあれば、そいつのhostsをいじってあげます。
rancher.your.hostを192.168.0.70とか、いま設定している(helmをインストールした)端末のIPにしてあげると、ブラウザでrancher.your.hostを開くとrancherが開けるようになります。

起動確認は以下

kubectl get pod -n cattle-system -w
kubectl get pod,svc,ingress -A

まだrancherを入れただけだと何もできませんが、ポチポチいろいろ押してみると楽しいでしょう。
今回ハマりがあるとすればkubeconfigの設定がちゃんと入っていなかったときだと思います。helmがちゃんと参照できるようにしておかないとうまくいきません。

次回は簡単なアプリケーションのデプロイです。

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