Skip to content

Latest commit

 

History

History
99 lines (90 loc) · 3.74 KB

02-deploy-app.md

File metadata and controls

99 lines (90 loc) · 3.74 KB

Chapter 2 - Deploy the Application to Kubernetes

Instructions

  1. Usekubectl to verify that you can connect to your cluster.

    kubectl get nodes

    You should see output like this:

    NAME                   STATUS   ROLES    AGE     VERSION
    pool-vj14tarbi-csyw0   Ready    <none>   30s   v1.22.8
    pool-vj14tarbi-csyw1   Ready    <none>   30s   v1.22.8
    pool-vj14tarbi-csywd   Ready    <none>   30s   v1.22.8
  2. Create a namespace where you will deploy your application

    kubectl apply -f kubernetes/namespace.yaml

    Check that your new namespace exists by running

    kubectl get namespaces

    You should see a list of namespaces, including the secrets-app, like this:

    NAME              STATUS   AGE
    default           Active   10m
    kube-node-lease   Active   10m
    kube-public       Active   10m
    kube-system       Active   10m
    secrets-app       Active   3s
  3. Create a Kubernetes Deployment that will ensure there are 3 replicas of the One Time Secret application running at once.

    kubectl apply -f kubernetes/deployment.yaml

    Check that there are three one-time-secret pods running in your secrets-app namespace.

    kubectl get pods -n secrets-app

    You should see something like this:

    NAME                              READY   STATUS    RESTARTS   AGE
    one-time-secret-5b757b96f-6nbm7   1/1     Running   0          12s
    one-time-secret-5b757b96f-b9t54   1/1     Running   0          12s
    one-time-secret-5b757b96f-cjtsx   1/1     Running   0          12s
  4. Deploy a service to create a Load Balancer that will direct traffic from the internet to your application replicas

    kubectl apply -f kubernetes/service.yaml

    Find the external IP address of the Load Balancer

    kubectl get svc -A

    You will see something like this:

    NAMESPACE       NAME          TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)                  AGE
    secrets-app     ots-service   LoadBalancer   10.245.26.224   143.198.247.38   80:31965/TCP             60m
    default         kubernetes    ClusterIP      10.245.0.1      <none>           443/TCP                  2d12h
    kube-system     kube-dns      ClusterIP      10.245.0.10     <none>           53/UDP,53/TCP,9153/TCP   2d12h

    It takes a few minutes for Load Balancer to be created and be assigned an IP address.

  5. Use httpie to verify your application works over the internet

  6. Test write

    http POST <load_balancer_ip_address>/secrets message="YOUR_MESSAGE" passphrase="YOUR_PASSPHRASE"
    1. Sample Response
    {
        "id": "ea54d2701885400cafd0c11279672c8f",
        "success": "True"
    }
  7. Test read, using the id from above

    http POST <load_balancer_ip_address>/secrets/<id> passphrase="YOUR_PASSPHRASE"
    1. Sample Response
    {
        "message": "Hello there",
        "success": "True"
    }

Stretch Goals

Learn More