2
6

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 3 years have passed since last update.

k3sをdocker-composeで起動する

Last updated at Posted at 2020-11-23

ソース取得

git clone git@github.com:rancher/k3s.git

起動する

cd k3s
K3S_TOKEN=${RANDOM}${RANDOM}${RANDOM} docker-compose up -d

kubectlに設定を参照するようにする

export KUBECONFIG=./kubeconfig.yaml

nodesを取得してみる

kubectl get nodes

出力

NAME           STATUS   ROLES    AGE   VERSION
65e2440e6916   Ready    <none>   11m   v1.19.4+k3s1
774f7268c91f   Ready    master   11m   v1.19.4+k3s1

dashboardをインストールする

GITHUB_URL=https://github.com/kubernetes/dashboard/releases
VERSION_KUBE_DASHBOARD=$(curl -w '%{url_effective}' -I -L -s -S ${GITHUB_URL}/latest -o /dev/null | sed -e 's|.*/||')
kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/${VERSION_KUBE_DASHBOARD}/aio/deploy/recommended.yaml
 echo 'apiVersion: v1                                                                                                                                                                    
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard' | kubectl apply -f -
echo 'apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kubernetes-dashboard' | kubectl apply -f -

tokenを取得する

kubectl -n kubernetes-dashboard describe secret admin-user-token | grep "^token"

proxyを起動してdashboardにアクセスする

kubectl proxy
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

image.png

refs

2
6
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
2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?