Follow

Follow
Deploy sample application di Kubernetes

Deploy sample application di Kubernetes

Abdul Rozaqi W's photo
Abdul Rozaqi W
·Jun 19, 2021·

1 min read

Di artikel sebelumnya kita sudah berhasil bagaimana cara menginstall kubernetes, sekarang kita akan coba deploy sample application di kubernetes.

  • Buat file untuk menyimpan konfigurasi aplikasi

sudo touch sample-application.yaml

Lalu copy dan paste script dibawah ke file yang sudah dibuat tadi

apiVersion: v1  
kind: Service  
metadata:  
  name: juiceshop  
  namespace: security  
  labels:  
    app.kubernetes.io/name: security  
spec:  
  type: NodePort  
  selector:  
    app: juiceshop  
  ports:  
    - name: juiceshop-port  
      protocol: TCP  
      port: 8080  
      targetPort: 3000  
---  
apiVersion: apps/v1  
kind: Deployment  
metadata:  
    name: juiceshop  
    namespace: security  
    labels:  
      app: juiceshop  
spec:  
    replicas: 1  
    selector:  
      matchLabels:  
        app: juiceshop  
    template:  
      metadata:  
        labels:  
          app: juiceshop  
      spec:  
        containers:  
        - name: juiceshop  
          image: docker.io/bkimminich/juice-shop  
          ports:  
          - containerPort: 3000

Save dan keluar dari nano

  • Buat namespaces
kubectl create ns security

  • Deploy aplikasi
kubectl apply -f sample-application.yaml

  • Cek pods dan service
sudo kubectl -n security get pods  
sudo kubectl -n security get svc

  • Akses IP Publik : Port