Skip to content

Latest commit

 

History

History
82 lines (71 loc) · 2.75 KB

01-app-setup.md

File metadata and controls

82 lines (71 loc) · 2.75 KB

Chapter 1 - Containerize an Application

Instructions

  1. Fork and Clone the Workshop Repository

  2. Have your developer environment setup

    1. You will need Docker and httpie on your local device
      1. Install Docker
      2. (optional) Install httpie
  3. Navigate to the Python Directory

    cd python
  4. (Optional) Review API endpoints in the Appendix

  5. (Optional) Create a Redis Cluster.

    • You can deploy the application without a Redis cluster, but there will be no data persistence.
    doctl databases create workshop-redis-cluster --engine redis --region sfo3
  6. Build the docker container

    docker build -t ots .
  7. Add your Redis credentials and run the image locally

    docker run -p 8080:8080 --env DB_HOST="<REDIS_HOST_URL>" --env DB_PORT="25061" --env DB_PASSWORD="<REDIS_PASSWORD>" --env DB_SSL=True ots
  8. Test with httpie

    1. Test write
      http POST localhost:8080/secrets message="YOUR_MESSAGE" passphrase="YOUR_PASSPHRASE"
      1. Sample Response
      {
         "id": "ea54d2701885400cafd0c11279672c8f",
         "success": "True"
      }
    2. Test read, using the id from above
      http POST localhost:8080/secrets/<id> passphrase="YOUR_PASSPHRASE"
      1. Sample Response
      {
          "message": "Hello there",
          "success": "True"
      }
  9. Create a DO Container Registry

    doctl registry create <your-registry-name> --region sfo3
  10. Use the registry login command to authenticate Docker with your registry:

    doctl registry login
  11. Use the docker tag command to tag your image with the fully qualified destination path:

    docker tag ots registry.digitalocean.com/<your-registry>/ots:0.0.1
  12. Use the docker push command to upload your image:

    docker push registry.digitalocean.com/<your-registry>/ots:0.0.1
  13. Allow your image to be used with your Kubernetes Cluster

    • Visit the registry page and click the Settings tab.
    • In the DigitalOcean Kubernetes integration section, click Edit to display the available Kubernetes clusters.
    • Select the clusters and click Save.
    • The default service account in each of those namespaces is updated to include the secret in its image pull secret.

Learn More