Created
August 18, 2018 09:14
-
-
Save ysaito8015/64d9bee3035ed0add7a2347a4364f2c0 to your computer and use it in GitHub Desktop.
Ubuntu 18.04 に kubernetes をインストールする ref: https://qiita.com/ysaito8015@github/items/26a208f9c482b2d2d24a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install docker.io | |
# systemctl で登録する | |
sudo systemctl enable docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - | |
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt update | |
sudo apt-get install kubeadm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo swapoff -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo kubeadm init --pod-network-cidr=10.114.0.0/16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 略 | |
Your Kubernetes master has initialized successfully! | |
To start using your cluster, you need to run the following as a regular user: | |
mkdir -p $HOME/.kube | |
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | |
sudo chown $(id -u):$(id -g) $HOME/.kube/config | |
You should now deploy a pod network to the cluster.↲ | |
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed | |
https://kubernetes.io/docs/concepts/cluster-administration/addons/ | |
You can now join any number of machines by running the following on each node | |
as root: | |
kubeadm join 10.114.51.231:6443 --token xxxxxx.xxxxxxxxxxxxx --discovery-token-ca-cert-hash sha256:xxxxxxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# この時点での get nodes | |
kubectl get nodes | |
NAME STATUS ROLES AGE VERSION | |
deer NotReady master 5m v1.11.2 | |
# この時点での get pods | |
kubectl get pods --all-namespaces=true | |
NAMESPACE NAME READY STATUS RESTARTS AGE | |
kube-system coredns-78fcdf6894-hptnd 0/1 Pending 0 1m | |
kube-system coredns-78fcdf6894-q6996 0/1 Pending 0 1m | |
kube-system etcd-deer 1/1 Running 0 45s | |
kube-system kube-apiserver-deer 1/1 Running 0 37s | |
kube-system kube-controller-manager-deer 1/1 Running 0 39s | |
kube-system kube-proxy-ksdvd 1/1 Running 0 1m | |
kube-system kube-scheduler-deer 1/1 Running 0 23s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl get nodes | |
NAME STATUS ROLES AGE VERSION | |
deer Ready master 12m v1.11.2 | |
kubectl get pods --all-namespaces=true -o wide | |
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE | |
kube-system coredns-78fcdf6894-hptnd 1/1 Running 0 14m 10.114.0.3 deer <none> | |
kube-system coredns-78fcdf6894-q6996 1/1 Running 0 14m 10.114.0.2 deer <none> | |
kube-system etcd-deer 1/1 Running 0 13m 10.114.51.28 deer <none> | |
kube-system kube-apiserver-deer 1/1 Running 0 13m 10.114.51.28 deer <none> | |
kube-system kube-controller-manager-deer 1/1 Running 0 13m 10.114.51.28 deer <none> | |
kube-system kube-flannel-ds-amd64-r5lxs 1/1 Running 0 2m 10.114.51.28 deer <none> | |
kube-system kube-proxy-ksdvd 1/1 Running 0 14m 10.114.51.28 deer <none> | |
kube-system kube-scheduler-deer 1/1 Running 0 13m 10.114.51.28 deer <none> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 証明書を作る | |
mkdir $HOME/certs | |
cd $HOME/certs | |
openssl genrsa 2048 > dashboard.key | |
openssl req -new -key dashboard.key > dashboard.csr | |
openssl x509 -days 3650 -req -signkey dashboard.key < dashboard.csr > dashboard.crt | |
# 作った証明書から secret を作る | |
kubectl create secret generic kubernetes-dashboard-certs --from-file=$HOME/certs -n kube-system | |
secret/kubernetes-dashboard-certs created | |
# yaml から apply する | |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml | |
# クラスターの状況 | |
kubectl cluster-info | |
Kubernetes master is running at https://10.114.51.28:6443 | |
KubeDNS is running at https://10.114.51.28:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy | |
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump' | |
# この時点の get pods | |
kubectl get pods -o wide --all-namespaces=true | |
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE | |
kube-system coredns-78fcdf6894-hptnd 1/1 Running 0 33m 10.114.0.3 deer <none> | |
kube-system coredns-78fcdf6894-q6996 1/1 Running 0 33m 10.114.0.2 deer <none> | |
kube-system etcd-deer 1/1 Running 0 33m 10.114.51.28 deer <none> | |
kube-system kube-apiserver-deer 1/1 Running 0 33m 10.114.51.28 deer <none> | |
kube-system kube-controller-manager-deer 1/1 Running 0 33m 10.114.51.28 deer <none> | |
kube-system kube-flannel-ds-amd64-r5lxs 1/1 Running 0 22m 10.114.51.28 deer <none> | |
kube-system kube-proxy-ksdvd 1/1 Running 0 33m 10.114.51.28 deer <none> | |
kube-system kube-scheduler-deer 1/1 Running 0 33m 10.114.51.28 deer <none> | |
kube-system kubernetes-dashboard-6948bdb78-l86vf 1/1 Running 0 6m 10.114.0.4 deer <none> | |
# kubectl proxy 起動 | |
kubectl proxy | |
Starting to serve on 127.0.0.1:8001 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment