k8s Quick-Start with Minikube

k8s Quick-Start with Minikube

  1. minikube
    1. Installation / Dashboard
  2. ArgoCD
    1. Installation / Dashboard
    2. Get password (User: admin)
  3. Harbor
    1. add repo
    2. fetch & unzip chart
    3. Installation
  4. MinIO deploying with ArgoCD
    1. git repositories
    2. MinIO Application creation with ArgoCD
    3. git repositories
    4. HOW-TO
  5. CI/CD with ArgoCD
    1. Sample Application with ArgoCD
  6. Jenkins
    1. Jenkins Installation with ArgoCD
  7. Nexus
    1. Nexus Installation with ArgoCD
  8. Top

minikube

Installation / Dashboard

minikube start
minikube dashboard

ArgoCD

Installation / Dashboard

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
minikube tunnel
minikube service argocd-server -n argocd

Get password (User: admin)

argocd admin initial-password -n argocd

Harbor

add repo

helm repo add harbor https://helm.goharbor.io
helm repo list

fetch & unzip chart

helm fetch harbor/harbor
tar zxvf harbor-x.x.x.tgz

Download: values.yaml

expose type to loadBalancer and tls disable

expose:
  type: loadBalancer
  ports:
    httpPort: 80
  tls:
    enabled: false # true

Installation

kubectl create ns hb
helm install harbor -f values.yaml . -n hb
minikube tunnel

browse to http://localhost
id: admin, password: Harbor12345


MinIO deploying with ArgoCD

git repositories

https://github.com/pushdown99/argo-minio.git

app/k8s-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: minio
spec:
  replicas: 1
  selector:
    matchLabels:
      app: minio
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: minio
    spec:
      volumes:
      - name: storage
        hostPath:
          path: /data/minio
      containers:
      - name: minio
        image: minio/minio:latest
        args:
        - server
        - --console-address
        - ":9001"
        - "/storage"
        env:
        - name: MINIO_ROOT_USER
          value: "minio"
        - name: MINIO_ROOT_PASSWORD
          value: "minio123"
        - name: TZ
          value: Asia/Seoul
        - name: LANG
          value: ko_KR.utf8
        ports:
        - containerPort: 9000
          hostPort: 9000
        - containerPort: 9001
          hostPort: 9001
        volumeMounts:
        - name: storage
          mountPath: "/storage"
---
apiVersion: v1
kind: Service
metadata:
  name: minio
  labels:
    run: minio
spec:
  type: NodePort
  ports:
  - port: 9000
    targetPort: 9000
    nodePort: 30333
    name: api
  - port: 9001
    targetPort: 9001
    nodePort: 30334
    name: ui
  selector:
    app: minio

MinIO Application creation with ArgoCD

git repositories

https://github.com/pushdown99/argo-minio.git

app/k8s-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myweb
spec:
  replicas: 2
  selector:
    matchLabels:
      app: myweb
  template:
    metadata:
      labels:
        app: myweb
    spec:
      containers:
      - name: myweb
        image: pushdown99/myweb:latest
        ports:
        - containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: myweb-service
spec:
  type: NodePort
  selector:
    app: myweb
  ports:
  - protocol: TCP
    port: 3000
    targetPort: 3000
    nodePort: 30000

HOW-TO

  1. Login to ArgoCD
  2. Applications > + New APP
  3. Fill-in

    • (GENERAL) Application Name: minio
    • (GENERAL) Project Name: default
    • (SOURCE) Repository URL: https://github.com/pushdown99/argo-minio.git
    • (SOURCE) Path: app
    • (DESTINATION) Cluster URL: https://kubernetes.default.svc
    • (DESTINATION) Namespace: default
  4. Create
  5. SYNC
  6. kubectl commands
kubectl get svc

NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                         AGE
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP                         35m
minio        NodePort    10.98.171.143   <none>        9000:30333/TCP,9001:30334/TCP   64s

kubectl port-forward svc/minio 9000:9000 9001:9001
  1. browse to http://127.0.0.1:9000

    id: minio, password: minio123

CI/CD with ArgoCD

Sample Application with ArgoCD

https://github.com/pushdown99/cicd-node.git

app/k8s-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myweb
spec:
  replicas: 2
  selector:
    matchLabels:
      app: myweb
  template:
    metadata:
      labels:
        app: myweb
    spec:
      containers:
      - name: myweb
        image: pushdown99/myweb:latest
        ports:
        - containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: myweb-service
spec:
  type: NodePort
  selector:
    app: myweb
  ports:
  - protocol: TCP
    port: 3000
    targetPort: 3000
    nodePort: 30000

HOW-TO

  1. Login to ArgoCD
  2. Applications > + New APP
  3. Fill-in

    • (GENERAL) Application Name: myweb
    • (GENERAL) Project Name: default
    • (SOURCE) Repository URL: https://github.com/pushdown99/cicd-node.git
    • (SOURCE) Path: app
    • (DESTINATION) Cluster URL: https://kubernetes.default.svc
    • (DESTINATION) Namespace: default
  4. Create
  5. SYNC
  6. kubectl commands
kubectl get svc

NAME            TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                         AGE
kubernetes      ClusterIP   10.96.0.1        <none>        443/TCP                         54m
minio           NodePort    10.98.171.143    <none>        9000:30333/TCP,9001:30334/TCP   20m
myweb-service   NodePort    10.104.220.233   <none>        3000:30000/TCP                  14m

kubectl port-forward svc/myweb-service 3000:3000
  1. browse to http://127.0.0.1:3000

Jenkins

Jenkins Installation with ArgoCD

https://github.com/pushdown99/argo-jenkins.git

HOW-TO

  1. Login to ArgoCD
  2. Applications > + New APP
  3. Fill-in

    • (GENERAL) Application Name: jenkins
    • (GENERAL) Project Name: default
    • (SOURCE) Repository URL: https://github.com/pushdown99/argo-jenkins.git
    • (SOURCE) Path: app
    • (DESTINATION) Cluster URL: https://kubernetes.default.svc
    • (DESTINATION) Namespace: default
  4. Create
  5. SYNC
  6. kubectl commands
minikube service jenkins-service -n jenkins

|-----------|-----------------|-------------|---------------------------|
| NAMESPACE |      NAME       | TARGET PORT |            URL            |
|-----------|-----------------|-------------|---------------------------|
| jenkins   | jenkins-service |        8080 | http://192.168.49.2:32000 |
|-----------|-----------------|-------------|---------------------------|
πŸƒ  jenkins-service μ„œλΉ„μŠ€μ˜ 터널을 μ‹œμž‘ν•˜λŠ” 쀑
|-----------|-----------------|-------------|------------------------|
| NAMESPACE |      NAME       | TARGET PORT |          URL           |
|-----------|-----------------|-------------|------------------------|
| jenkins   | jenkins-service |             | http://127.0.0.1:44853 |
|-----------|-----------------|-------------|------------------------|
πŸŽ‰  Opening service jenkins/jenkins-service in default browser...
❗  windows μ—μ„œ Docker λ“œλΌμ΄λ²„λ₯Ό μ‚¬μš©ν•˜κ³  있기 λ•Œλ¬Έμ—, 터미널을 μ—΄μ–΄μ•Ό μ‹€ν–‰ν•  수 μžˆμŠ΅λ‹ˆλ‹€

Find password for access page http://127.0.0.1:44853

kubectl get pod -n jenkins

NAME                       READY   STATUS    RESTARTS   AGE
jenkins-6846f7864d-957b8   1/1     Running   0          2m8s

kubectl -n jenkins exec -it jenkins-6846f7864d-957b8 -- /bin/bash

jenkins@jenkins-6846f7864d-957b8:/$ cat /var/jenkins_home/secrets/initialAdminPassword
  1. browse to http://127.0.0.1:44853

Nexus

Nexus Installation with ArgoCD

https://github.com/pushdown99/argo-nexus.git

HOW-TO

  1. Login to ArgoCD
  2. Applications > + New APP
  3. Fill-in

    • (GENERAL) Application Name: nexus
    • (GENERAL) Project Name: default
    • (SOURCE) Repository URL: https://github.com/pushdown99/argo-nexus.git
    • (SOURCE) Path: app
    • (DESTINATION) Cluster URL: https://kubernetes.default.svc
    • (DESTINATION) Namespace: default
  4. Create
  5. SYNC
  6. kubectl commands
minikube service nexus-service -n nexus

|-----------|---------------|-------------|---------------------------|
| NAMESPACE |     NAME      | TARGET PORT |            URL            |
|-----------|---------------|-------------|---------------------------|
| nexus     | nexus-service |        8081 | http://192.168.49.2:30100 |
|-----------|---------------|-------------|---------------------------|
πŸƒ  nexus-service μ„œλΉ„μŠ€μ˜ 터널을 μ‹œμž‘ν•˜λŠ” 쀑
|-----------|---------------|-------------|------------------------|
| NAMESPACE |     NAME      | TARGET PORT |          URL           |
|-----------|---------------|-------------|------------------------|
| nexus     | nexus-service |             | http://127.0.0.1:60009 |
|-----------|---------------|-------------|------------------------|
πŸŽ‰  Opening service nexus/nexus-service in default browser...
❗  windows μ—μ„œ Docker λ“œλΌμ΄λ²„λ₯Ό μ‚¬μš©ν•˜κ³  있기 λ•Œλ¬Έμ—, 터미널을 μ—΄μ–΄μ•Ό μ‹€ν–‰ν•  수 μžˆμŠ΅λ‹ˆλ‹€

Find password for access page http://127.0.0.1:60009

kubectl get pod -n nexus

NAME                     READY   STATUS    RESTARTS   AGE
nexus-65b596bb55-rv47v   1/1     Running   0          5m34s

kubectl -n nexus exec -it nexus-65b596bb55-rv47v -- /bin/bash

bash-5.1$ cat /nexus-data/admin.password
  1. browse to http://127.0.0.1:60009

Top

kubectl top node

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

Β© 2018. All rights reserved.

Powered by Hydejack v8.4.0