Create kubernetes_dashboard_setup.sh

This commit is contained in:
Torma Kristóf 2019-03-18 23:41:25 +01:00 committed by GitHub
parent 0760f57617
commit 4105f08935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,23 @@
#!/bin/bash
#Gen certificates
mkdir -p certs
cd certs
CERT_DIR=$PWD
openssl genrsa -des3 -passout pass:x -out dashboard.pass.key 2048
openssl rsa -passin pass:x -in dashboard.pass.key -out dashboard.key
rm dashboard.pass.key
openssl req -new -key dashboard.key -out dashboard.csr -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com"
openssl x509 -req -sha256 -days 365 -in dashboard.csr -signkey dashboard.key -out dashboard.crt
kubectl create secret generic kubernetes-dashboard-certs --from-file=$CERT_DIR -n kube-system
cd ..
#Deploy the dashboard
#wget https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
wget https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml
sed -i '176i\ type: LoadBalancer' kubernetes-dashboard.yaml
kubectl apply -f kubernetes-dashboard.yaml
#Token based dashboard authentication
kubectl create serviceaccount k8sadmin -n kube-system
kubectl create clusterrolebinding k8sadmin --clusterrole=cluster-admin --serviceaccount=kube-system:k8sadmin