Kubernetes
Salta a la navegació
Salta a la cerca
Kubernetes Administration training
https://beta.etherpad.org/p/cgi
Two machines/nodes for testing.
On the Master node:
sudo apt-get update sudo apt-get install -y apt-transport-https sudo su - curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add cat <<EOF > /etc/apt/sources.list.d/kubernetes.list deb http://apt.kubernetes.io/ kubernetes-xenial main EOF apt-get update apt-get install -y docker.io apt-get install -y kubelet kubeadm kubectl kubernetes-cni systemctl enable docker.service # kubeadm init # only one of the following 3: # WEAVE kubeadm init kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')" #flanel kubeadm init --pod-network-cidr=10.244.0.0/16 kubectl apply -f "https://raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml" # calico kubeadm init --pod-network-cidr=10.233.64.0/18 kubectl apply -f "https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml" kubectl apply -f "https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml"
On the Worker Node:
sudo apt-get update sudo apt-get install -y apt-transport-https sudo su - curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add cat <<EOF > /etc/apt/sources.list.d/kubernetes.list deb http://apt.kubernetes.io/ kubernetes-xenial main EOF apt-get update apt-get install -y docker.io apt-get install -y kubelet kubeadm kubernetes-cni systemctl enable docker.service kubeadm join <connection parameters>
Create the following file marti.yaml:
apiVersion: v1 kind: ServiceAccount metadata: name: martiusername namespace: martinamespace --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: martiusername roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: martiusername namesapce: martinamespace
Execute it with:
kubectl create -f marti.yaml
Instead of:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
Download https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml and replace the last part with:
spec: type: NodePort ports: - port: 8443 nodePort: 30080
kubectl apply -f kubernetes-dashboard-EDITED.yaml
Using Firefox try to connect to the the dashboard using the public ip:30080
To know which token run on the master:
# kubectl -n martinamespace describe secret $(kubectl -n kube-system get secret | grep martiusername | awk ' {print $1}') kubectl -n martinamespace describe secret $(kubectl -n martinamespace get secret | grep martiusername | awk ' {print $1}')