0
0

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 1 year has passed since last update.

K8s の実験(その2:環境構築2)

Last updated at Posted at 2023-02-26

k8sの実験(その1:環境構築1)のつづき

Fedora がローカルマシンとなりますので、以下のページを参考にして、kubectl をインストールします。

(参考)
https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
enabled=1
gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
sudo yum install -y kubectl

kubectl コマンドが使えるかどうか、やってみます。

$ kubectl 

ヘルプが表示されたので、使えるようです。
以下のコマンドを実行してみます。

$ kubectl get nodes
The connection to the server localhost:8080 was refused - did you specify the right host or port?

DigitalOcean からダウンロードした、設定ファイルを読み込む必要があるようです。

$ kubectl --kubeconfig "<path to yaml file>" get nodes
NAME                        STATUS   ROLES    AGE   VERSION
xxxx-worker-node-qbbfo   Ready    <none>   34m   v1.25.4

いちいち、--kubeconfig オプションをつかうのも面倒です。
以下のようにすることで、オプションを追加しなくても node のじょうたいが確認できるようになります。

$ mkdir ~/.kube
$ cp ~/k8s/i<path to yaml file> ~/.kube/config

--kubeconfig オプションを追加せずにコマンドを実行してみます。

$ kubectl get nodes
NAME                        STATUS   ROLES    AGE   VERSION
xxxx-worker-node-qbbfo   Ready    <none>   40m   v1.25.4

K8S の実験(その3:pod の作成・削除)につづく。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?