Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

cloudfoundry-attic/diego-docker-cache-release

Repository files navigation

diego-docker-cache

BOSH release for Diego Docker Cache


Initial Setup

This BOSH release doubles as a $GOPATH. It will automatically be set up for you if you have direnv installed.

# fetch release repo
mkdir -p ~/workspace
cd ~/workspace
git clone https://github.com/cloudfoundry-incubator/diego-docker-cache.git
cd diego-docker-cache/

# automate $GOPATH and $PATH setup
direnv allow

# initialize and sync submodules
./scripts/update

If you do not wish to use direnv, you can simply source the .envrc file in the root of the release repo. You may manually need to update your $GOPATH and $PATH variables as you switch in and out of the directory.


Deploying to a local BOSH-Lite instance

  1. Follow the instructions in Diego Release and install CF

  2. When generating the Diego's manifest (step 9) use the following set of files instead:

     cd ~/workspace/diego-release
     ./scripts/generate-deployment-manifest \
       ~/workspace/diego-docker-cache-release/stubs-for-diego-release/bosh-lite-property-overrides.yml \
       manifest-generation/bosh-lite-stubs/instance-count-overrides.yml \
       manifest-generation/bosh-lite-stubs/persistent-disk-overrides.yml \
       manifest-generation/bosh-lite-stubs/iaas-settings.yml \
       manifest-generation/bosh-lite-stubs/additional-jobs.yml \
       manifest-generation/bosh-lite-stubs/release-versions.yml \
       ~/workspace/cf-release/bosh-lite/deployments \
       > ~/workspace/diego-release/bosh-lite/deployments/diego.yml
     bosh deployment ~/workspace/diego-release/bosh-lite/deployments/diego.yml
    
  3. Deploy Diego:

     bosh create release --force
     bosh -n upload release
     bosh -n deploy
    
  4. Generate and target Diego Docker Cache's manifest:

     cd ~/workspace/diego-docker-cache-release
     ./scripts/generate-bosh-lite-manifest
     bosh deployment ~/workspace/diego-docker-cache-release/bosh-lite/deployments/docker-cache.yml
    
  5. Deploy the Docker Cache:

     bosh create release --force
     bosh -n upload release
     bosh -n deploy
    

Configuring registry

Backend storage

You can configure the Docker Registry backend storage in property-overrides.yml. Here is what you have to include for each supported storage type:

Filesystem

This is the default storage type. You can simply omit the property overrides or explicitly add:

docker_registry:
  storage:
    name: filesystem

AWS S3

docker_registry:
  storage:
    name: s3
    s3:
      bucket: <bucket name>
      accesskey: <access key>
      secretkey: <secret key>
      region: <region name, i.e. us-east-1>

Save the property changes and then generate the manifest and deploy the Diego Docker Cache release.

TLS

Docker Registry can be configured to use TLS for secure communication. To do this:

  1. Obtain a certificate and key. This can be done with OpenSSL:

     openssl genrsa -out server.key 1024
     openssl req -new -key server.key -out server.csr
     openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
    
  2. Edit property-overrides.yml. You have to add the generated certificate and key:

     docker_registry:
       tls:
         enabled: true
         certificate: |
           -----BEGIN CERTIFICATE-----
           ... content of server.crt file ...
           -----END CERTIFICATE-----
         key: |
           -----BEGIN RSA PRIVATE KEY-----
           ... content of server.key file ...
           -----END RSA PRIVATE KEY-----
    

Save the property changes and then generate the manifest and deploy the Diego Docker Cache release.

Running Acceptance Tests

See docker-cache-acceptance-tests

Caching docker image with Diego

  1. Install CF CLI v6.10.0+ (or follow the guide in Migrating to Diego)

  2. Install diego-beta CLI Plugin

     cf add-plugin-repo CF-Community http://plugins.cloudfoundry.org/
     cf install-plugin Diego-Beta -r CF-Community
    
  3. Login to CF

     cf api --skip-ssl-validation api.10.244.0.34.xip.io
     cf auth admin admin
    
  4. Push your docker application

     cf docker-push <application_name> <docker_image> --no-start
    
  5. Enable caching by setting DIEGO_DOCKER_CACHE boolean environment variable

     cf set-env <application_name> DIEGO_DOCKER_CACHE true
    
  6. Start the application:

     cf start <application_name>