Docker and Kubernetes

Shawn Fu
1 min readJul 17, 2021

Docker

To run SonarQube in detached mode, execute following command:

docker run -d -p 9000:9000 --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true sonarqube

Kubernetes

To deploy dashboard, execute following command:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.3.1/aio/deploy/recommended.yaml

To access dashboard, execute following command:

nohup kubectl proxy &

To create a service account, execute following command:

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
EOF

To create a cluster role binding, execute following command:

cat <<EOF | kubectl apply -f -
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
EOF

To get a token, execute following command:

kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}"

Now access dashboard at:

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

You can add a skip button in the login page by following these steps:

  1. Switch namespace to kubernetes-dashboard.
  2. Edit the deployments named kubernetes-dashboard.
  3. Add - '--enable-skip-login' in .spec.template.spec.containers.args.

To install the metrics server, execute following command:

kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml

To disable certificate validation by following these steps:

  1. Switch namespace to kube-system.
  2. Edit the deployments named metrics-server.
  3. Add - '--kubelet-insecure-tls' in .spec.template.spec.containers.args.

--

--