5
3

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.

k3s動かしてみた (1台構成)

Last updated at Posted at 2019-03-01

VirtualBox上のubuntu 18.10 (x86_64)にて実施。

ダウンロード

スクリーンショット_2019-03-01_10-42-18.png

server起動

# 実行権限
chmod +x k3s

# server起動
sudo ./k3s server

# node一覧確認 (Readyであること)
sudo ./k3s kubectl get node

# nodeを追加したい場合、以下のtokenを使うらしい
sudo cat /var/lib/rancher/k3s/server/node-token

# nodeをtoken指定で追加する場合。IPとtoken値を適宜修正。
sudo ./k3s agent --server https://192.168.9.9:6443 \
 --token "K10d2c5c59d6eece74ffad3f5a3bd8ec034b2608cdfcf07ec88312978ba252c1892::node:2cb458aa6092629dbcbff65e53440dab"
  • ./k3s serverを停止すると./k3s kubectlを受け付けなくなるので注意。

pods作成

pod-nginx.yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
spec:
  containers:
    - name: nginx-container
      image: nginx
      ports:
      - containerPort: 80
# pod起動
sudo ./k3s kubectl create -f pod-nginx.yaml

# pod一覧確認
sudo ./k3s kubectl get pod
status(Runningであること)
NAME        READY   STATUS    RESTARTS   AGE
nginx-pod   1/1     Running   0          7m54s

画面確認

ポートフォワード
# port8080 に nginxコンテナのport80を割り当て
sudo ./k3s kubectl port-forward nginx-pod 8080:80

localhost.png

後片付け

podsの削除
sudo ./k3s kubectl delete pods --all
  • containerd-shimプロセスが残る。これの止めかたがわからなかったので以下のようにした。
sudo killall containerd-shim
5
3
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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?