Skip to content

Instantly share code, notes, and snippets.

@lucasjellema
Last active December 12, 2021 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasjellema/a7756f21a0e639495553b6a6d79eb788 to your computer and use it in GitHub Desktop.
Save lucasjellema/a7756f21a0e639495553b6a6d79eb788 to your computer and use it in GitHub Desktop.
OKE-dashboard-app-deployment

Get Kubernetes Dashboard Running

Install Dashboard on Cluster kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.4.0/aio/deploy/recommended.yaml

Verify the deployment kubectl -n kubernetes-dashboard get pods

Proxy Cluster kubectl proxy

Access Dashboard in browser via http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login

Create a file oke-admin-service-account.yaml to create a Service Account with the following contents:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: oke-admin
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: oke-admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: oke-admin
  namespace: kube-system

Apply the yaml file just created to have the ClusterRoleBinding and ServiceAccount resources created kubectl apply -f oke-admin-service-account.yaml

Using the now newly service account, retrieve the token kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep oke-admin | awk '{print $1}')

Deploy/Run a First Application

Create a yaml file with the definition of a deployment and a service (of type LoadBalancer)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: docker-hello-world
  labels:
    app: docker-hello-world
spec:
  selector:
    matchLabels:
      app: docker-hello-world
  replicas: 3
  template:
    metadata:
      labels:
        app: docker-hello-world
    spec:
      containers:
      - name: docker-hello-world
        image: scottsbaldwin/docker-hello-world:latest
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: docker-hello-world-svc
spec:
  selector:
    app: docker-hello-world
  ports:
    - port: 8088
      targetPort: 80
  type: LoadBalancer

Apply this file to create the application resources kubectl create -f hello-world-app.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment