Giter Club home page Giter Club logo

paas-cf's Introduction

paas-cf

⚠️ When merging pull requests, use the gds-cli: gds git merge-sign alphagov/paas-cf PR_NUMBER ⚠️

GOV.UK Platform as a Service (PaaS) CF creates a deployment of Cloud Foundry (CF) on VMs for GOV.UK PaaS. It builds upon the foundations laid out in paas-bootstrap and it handles the following non-exhaustive list of duties:

It does not include the AWS IAM roles which are assumed by different system components. Those are created in the account wide terraform (private repository).

Contents

  1. What does paas-cf contain?
  2. Deploying a new environment
  3. Cloud Foundry deployment configuration options
  4. Accessing Concourse
  5. Finding configuration
  6. Utility Scripts

What does paas-cf contain?

paas-cf separates the responsibility for configuring, deploying, running, and monitoring Cloud Foundry, from those responsibilities held by paas-bootstrap.

This repository does not itself contain the code that runs in an environment (for the most part), but instead serves to compose the different pieces into a cohesive whole. As a result, it contains a variety of pieces that tell only part of the story. The table under the heading Finding configuration outlines some key directories and their purposes.

Deploying a new environment

At a very high level, the create-cloudfoundry Concourse pipeline generates a Bosh manifest which describes the virtual machines and their networking which make up the Cloud Foundry deployment, as well as the software which runs on each machine. The manifest is then submitted to the Bosh director configured in paas-bootstrap.

Pre-requisites

Before you can get a Cloud Foundry deployment up and running, you will need the following available

  • A running deployer-concourse instance from paas-bootstrap
  • Make
  • Ruby >= 2.7
  • GDS CLI
  • Access to paas-credentials (private repository) and tools installed
  • Connection to GDS VPN
  • Permission to assume the Admin role of the relevant AWS account (dev, ci, staging, production)
  • AWS_DEFAULT_REGION environment set the desired region for the environment
  • cf CLI >=7

Deploy Cloud Foundry

These instructions contain placeholders where the exact command may vary. The below table explains the purpose of those placeholders:

Placeholder Purpose
$ACCOUNT The AWS account being targeted (for example, dev, staging)
$ENV The name of the environment being targeted. In the case of short lived development environments, this should have a value of dev, and the specific environment is set by the DEPLOY_ENV environment variable (max 8 chars)
  1. Log in to CredHub in the environment by running this and following the instructions on screen. This will take you into a new shell session.

    gds aws paas-$ACCOUNT-admin -- make $ENV credhub
  2. Upload the secrets to CredHub from the CredHub shell session.

    make $ENV upload-all-secrets

    Note: you do not need to use GDS CLI here because the CredHub shell session contains the AWS credentials in environment variables

  3. Exit the CredHub shell session

  4. Deploy the pipeline configurations using make. This will upload or update the pipelines. Select the target based on which AWS account you want to work with:

    gds aws paas-$ACCOUNT-admin -- make $ENV pipelines
  5. Log in to Concourse. See the Accessing Concourse.

  6. Tun the generate-paas-admin-git-keys, generate-paas-billing-git-keys and generate-paas-aiven-broker-git-keys jobs in the job group operator. This will generate and store some SSH keys needed by other jobs.

  7. Run the create-cloudfoundry pipeline, starting from the left-hand pipeline-lock job. This will configure and deploy Cloud Foundry. It might take a couple of hours to complete.

Cloud Foundry deployment configuration options

There are a handful of configuration options which can change a Cloud Foundry deployment which can only be set at pipeline level. Each of the properties in the below table should be set as Make variables when setting the pipelines:

gds aws paas-$ACCOUNT-admin -- make $ENV pipelines VAR=value
Property (VAR) Type Default Description
BRANCH String main Sets the paas-cf branch which will be used in the pipeline
DEPLOY_ENV String null for short-lived dev envs, fixed in Makefile for other envs Sets the name of the environment
SELF_UPDATE_PIPELINE Bool true Whether the pipeline should update its own definition from the current branch at runtime. Disable this if you're making a pipeline change which has not been pushed to branch yet
SLIM_DEV_DEPLOYMET Bool true in dev, false elsewhere If true, reduces the number and size of VMs created for each component to 2. In dev, set this to false when testing the impact of a change on platform availability
DISABLED_AZS String list, space separated ""

Disables the given availability zones in Bosh. This is used when an availability zone goes away, and we need to redistribute virtual machines away from that AZ.

Set to a value like "z1 z2"

ENABLE_AUTODELETE Bool true in dev, false elsewhere

If true, deploys a pipeline which tears down Cloud Foundry at 8pm each day as a cost saving measure.

This should absolutely never be set to true in a staging or production deployment

ENABLE_DESTROY Bool true in dev, false elsewhere

If true, deploys a pipeline which, when run, will completely destroy Cloud Foundry and all of its data

This should absolutely never be set to true in a staging or production deployment

Accessing Concourse

Once deployed, Concourse can be accessed from the URLs below. By default, authentication with Github is enabled.

Environment type Environment name URL
Dev Unique name https://deployer.$NAME.dev.cloudpipeline.digital/
Dev Dev[0-9]+ https://deployer.dev$NUMBER.dev.cloudpipeline.digital/
Staging stg-lon https://deployer.london.staging.cloudpipeline.digital/
CI build https://concourse.build.ci.cloudpipeline.digital/
Production prod https://deployer.cloud.service.gov.uk/
Production prod-lon https://deployer.london.cloud.service.gov.uk/

Non-development URLs are also accessible via the gds paas open command.

Finding configuration

The following table outlines some important directories in the repository, their purpose, and when you might need to look in them.

Directory Purpose I will need this when ..
concourse/pipelines/ YAML definitions of the Concourse pipelines I want to make a change to how the platform is deployed, monitored, or torn down
config/billing/ The scripts and static files used to generate configuration for the billing system.
  • I'm adding a new backing service, so that I can set how much it costs.
  • The VAT rate has changed
  • The cost of an AWS resource has changed
manifests/cf-manifest/ The Bosh manifest configuration for Cloud Foundry See specific directories below
manifests/cf-manifest/operations.d/ Customisations applied to cf-deployment, applicable to all environments
  • I want to make a configuration change that will affect every environment
  • I want to deploy a new piece of software with a Bosh release
manifests/cf-manifest/operations Customisations applied to cf-deployment based on some condition I want to make a configuration change that will only be applied in certain circumstances
manifests/cf-manifest/spec Unit tests applied to the generated manifest file I want to make sure a property of the manifest is not invalidated (for example, correct number of instances of some VM)
manifests/cf-manifest/env-specific Values of variables per environment I want to change things like the number of Diego cells deployed in an environment
terraform/az-monitoring Terraform configuration for out availability zone monitoring solution I want to make a change to how we monitoring how alive an availability zone is
terraform/cloudfoundry Terraform configuration for the AWS resources associated with running Cloud Foundry
  • I want to set/unset DNS records
  • I want to configure ingress for a new service broker
  • I want to alter Cloud Foundry's AWS network architecture
terraform/spec Unit tests applied to Terraform configuration I want to make an assertion about Terraform configuration as part of the unit tests
terraform/vpc-peering Terraform configuration for VPC peering between the Cloud Foundry VPC and others I want to change a property of our existing VPC peers, and future ones
tools/buildpacks Golang implementation of our regular buildpack update emails I want to make a change to the email we send to tenants about buildpack updates
tools/metrics A Prometheus exporter which exposes a variety of platform-level metrics collected from different sources
  • I want to add a new metrics
  • I want to change the frequency of the measurement of an existing metric

Utility Scripts

Add a permissions boundary policy to paas-s3-broker users

Configure the POLICY_NAME variable within the Makefile with the name of the Permissions Boundary policy that you wish to add to the paas-s3-broker users.

Run this command to add a permissions boundary to paas-s3-broker users:

gds aws paas-<ENV-ROLE> -- make <BUILD_ENV> add_permissions_boundary_to_existing_s3_broker_users ARGS="<--dry-run>"

Replace:

  • <ENV-ROLE> with the environment and role that you want to use e.g. prod-admin.
  • <BUILD_ENV> with the environment that you want to update e.g. prod-lon.
  • Only use the --dry-run flag if you would like the script to run but not change anything.

If the command is successful, the output will look similar to this:

Dry run? false
Policy attached to user: paas-s3-broker-dev05-0a094c73-7ae7-42cc-b028-6c78b93985d7
Policy attached to user: paas-s3-broker-dev05-dad332ff-3557-4f13-a768-5dc0e8421cd4

paas-cf's People

Contributors

46bit avatar actionjack avatar alext avatar ap-hunt avatar cadmiumcat avatar camelpunch avatar corlettb avatar dark5un avatar dcarley avatar fearoffish avatar harsh291104 avatar henrytk avatar jackjoy-gds avatar jonty avatar keymon avatar krenair avatar malcgds avatar mogds avatar monotypical avatar mtekel avatar nimalank7 avatar paroxp avatar richardc avatar richardtowers avatar risicle avatar saliceti avatar samcrang avatar schmie avatar timmow avatar whi-tw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paas-cf's Issues

Hardcoded DNS names and Route53 Zone IDS in Makefile and TFVars

Because the terraform runs happen within the Concourse deployment pipeline(s), the use of hardcoded DNS names and Zone IDs within the TFVars makes it necessary to fork paas-cf and update pipelines to pull from the forked repo instead.

It would be great for other organisations outside GDS to be able to deploy paas-cf without having to fork the codebase.

Use docker_resource as a resource to "pin" a dependency

I want to suggest an improvement for your pipelines to pin the version of the containers.

I suggest this here because there is no other official channel to communicate.

In concourse, you can use a resource as image for a task, by using the get instead of specify task.config.docker_resource.

This way you are pining the version of the container to use:

diff --git a/concourse/pipelines/create-cloudfoundry.yml b/concourse/pipelines/create-cloudfoundry.yml
index 810c3d7..21af57d 100644
--- a/concourse/pipelines/create-cloudfoundry.yml
+++ b/concourse/pipelines/create-cloudfoundry.yml
@@ -55,6 +55,7 @@ groups:
   - name: credentials
     jobs:
       - clear-cloudfoundry-credentials
+
 resource_types:
 - name: s3-iam
   type: docker-image
@@ -67,6 +68,11 @@ resource_types:
     repository: governmentpaas/semver-resource
 
 resources:
+  - name: cf-acceptance-tests-container
+    type: docker-image
+    source:
+      repository: governmentpaas/semver-resource
+
   - name: pipeline-trigger
     type: semver-iam
     source:
@@ -1129,6 +1135,8 @@ jobs:
           - get: graphite-nozzle
           - get: datadog-tfstate
           - get: paas-rubbernecker
+          - get: cf-acceptance-tests-container
+            passed: ['cf-deploy']
 
       - aggregate:
         - task: extract-cf-terraform-outputs
@@ -1931,7 +1939,8 @@ jobs:
           - get: bosh-CA
           - get: cf-secrets
             passed: ['cf-deploy']
-
+          - get: cf-acceptance-tests-container
+            passed: ['cf-deploy']
       - do:
         - task: create-temp-user
           file: paas-cf/concourse/tasks/create_admin.yml
@@ -1972,7 +1981,7 @@ jobs:
                     ./cf-release/jobs/acceptance-tests/spec \
                     acceptance_test_properties.yml \
                       > ./test-config/run
-
+                                                                        t
                   chmod +x ./test-config/run
 
                   ./paas-cf/platform-tests/bosh-template-renderer/render.rb \
@@ -1983,11 +1992,9 @@ jobs:
 
         - task: run-tests
           config:
+            image: cf-acceptance-tests-container
             platform: linux
-            image_resource:
-              type: docker-image
-              source:
-                repository: governmentpaas/cf-acceptance-tests
+g
             params:
               DISABLE_CF_ACCEPTANCE_TESTS: {{disable_cf_acceptance_tests}}
             inputs:

Pre-requisites section does not incldue the shared-cf-blobstore bucket-<env>

The pre-requisites section of the documentation does not include details about the creation of the shared-cf-blosh-blobstore- bucket(s). These buckets are not created by the paas-cf pipeline, so should be listed in the pre-requisites section.

Further to this, because S3 bucket names are globally unique, it is not possible for any other organisation outside of GDS to use the same bucket-name format, so it would be good to be able to parametrise the shared-cf-bosh-blobstore- part of the bucket name for different organisations to be able to use paas-cf without having to fork and change code.

Required IAM Instance profiles are not listed in the pre-requisites section.

The README.md states that IAM instance profiles are configured through the account-wide-terraform repository and that it is not publically accessible due to the state file being stored within that repository. No further details of the required instance profiles are provided.

The following IAM instance profiles are required as pre-requisites before deployment can complete successfully.

  • bootstrap-concourse
  • deployer-concourse
  • bosh-director
  • bosh-managed
  • cf-cloudcontroller
  • rds-broker

It would be really great if a sanitised version of the account-wide-terraform repository could be provided, but failing that, details of the required IAM roles and policies for each instance profile should be documented fully.

Potential import collision: import path should be "github.com/go-acme/lego", not "github.com/xenolf/lego".

Background

The lego has already renamed it’s import path from "github.com/xenolf/lego" to "github.com/go-acme/lego".

But gomodules/dns still used the old path:
https://github.com/alphagov/paas-cf/blob/master/tools/user_emails/go.mod#L17

github.com/xenolf/lego v2.5.0+incompatible

When you use the old path "github.com/xenolf/lego" to import the lego, it will be very easy to reintroduce lego through the import statements "import github.com/go-acme/lego" in the go source file of lego.
https://github.com/go-acme/lego/blob/v2.5.0/acme/api/authorization.go#L6

package main
import (
	"fmt"
	"github.com/go-acme/lego"
	"net/http"
)
…

The "github.com/go-acme/lego" and "github.com/xenolf/lego" are the same repos. This will work in isolation, bring about potential risks and problems.

Solution

Replace all the old import paths, change "github.com/xenolf/lego" to "github.com/go-acme/lego".
Where did you import it: https://github.com/alphagov/paas-cf/search?q=github.com%2Fxenolf%2Flego&unscoped_q=github.com%2Fxenolf%2Flego

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.