Help us understand the problem. What is going on with this article?

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

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
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away