Giter Site home page Giter Site logo

kingjay66 / anthos-security-blueprints Goto Github PK

View Code? Open in Web Editor NEW

This project forked from googlecloudplatform/anthos-security-blueprints

0.0 1.0 0.0 242 KB

Implementation steps and assets for Google Cloud Anthos blueprints https://cloud.google.com/architecture/blueprints/anthos-security-blueprints-faq

License: Apache License 2.0

Shell 52.51% HCL 47.49%

anthos-security-blueprints's Introduction

Cloud Security Blueprints for Anthos

This repository contains the deployable assets that are part of the Google Cloud Security blueprints for Anthos. The Google Cloud Security blueprints for Anthos are granular and address specific security postures.

The instructions and accompanying assets in this repo are for the following Google Cloud Security blueprints for Anthos:

The blueprints can be used in any combination. Note: If you need to constraint what regions your clusters can be deployed to the steps detailed in the Enforcing locality restrictions blueprint should be followed first before using any other Anthos security blueprint.

This repository for the set of blueprints is to be used with a structured Anthos config management repo

Example Anthos config management Structured repo configuration:




── config-root/ # directory ACM monitors for policy
   ├── README.md
   ├── system/ # configs for the Operator
   ├── namespaces/ configs for namespaces and namespace-scoped objects. Structure determines namespace inheritance
   ├── cluster/ #  configs for cluster scoped objects
   |    | - # Put Your Policy Controller constraints here
   └── clusterregistry/ # configs for cluster selectors - limits which clusters a config applies to 
       ├── cluster.mycluster.yaml
       ├── clusterregistry.select-location-clusterx.yaml
       └── clusterregistry.select-prod.yaml

We recommend you read through the full README but if you just want to get started

  1. Ensure the assumptions are met
  2. Follow the steps in prerequisites
  3. Configure your workstation environment
  4. Clone the repo
  5. Configure Cloud Platform IAM
  6. Follow the deployment steps

If you have already implemented one of the Anthos specific blueprints for your Anthos clusters in this series you do not need to repeat the prerequisites and deployment steps described in this README

The blueprints outlined in this repo are additive so you can apply multiple blueprints to your clusters.

Follow through the detailed deployment steps for each individual blueprint by following the steps detailed in the README for the specific blueprint folder.

If you wish to start from an end to end example follow the steps outlined in the example README that mostly closely meets the security posture you wish to apply to your clusters.

Note: each blueprint in the series assumes you have Policy Controller installed which is a recommendation in the hardening guides

  • Each cluster has the Anthos Config Management Operator installed
  • Network policies are required and you created your cluster with the --enable-network-policy flag . This step provides you with the ability to implement firewall rules that restrict what traffic can flow between pods in a cluster
  • You have defined the namespaces and labels required for the pods. This provides you with a name scope that allows you to work with policies and Kubernetes service accounts
  • You have some familiarity with Anthos Config Management. If you have not used Anthos config Management before familiarise yourself by following the quickstart
  • You are familiar with git

Prepare your admin workstation

You can use Cloud Shell, a local machine or VM as your admin workstation

Tools for Cloud Shell as your Admin workstation

Tools for a local workstation as your Admin workstation

Installation instructions for Tools for your environment

Install Cloud SDK

This is pre installed if you are using Cloud Shell

The Google Cloud SDK is used to interact with your GCP resources. Installation instructions for multiple platforms are available online.

Install kubectl CLI

The kubectl CLI is used to interact with both Kubernetes Engine and kubernetes in general. Installation instructions for multiple platforms are available online.

Install the nomos CLI

Install the nomos CLI for managing ACM across clusters

Install Terraform

Terraform is used to automate the manipulation of cloud infrastructure. Its installation instructions are also available online. When configuring terraform for use with Google cloud create a service account as detailed in Getting started with the google provider

Authentication

After installing the gcloud SDK run gcloud init to set up the gcloud cli. When executing choose the correct region and zone

'gcloud init'

Ensure you are using the correct project . Replace my-project-name with the name of your project

Where the project name is my-project-name

gcloud config set project my-project-name

Clone this repo

Important :If you are implementing multiple blueprints you only need to clone the repo once

In your terminal, clone this repo locally.

  $ git clone https://github.com/<GITHUB\_USERNAME>/xyz.git


  $ cd xyz/docs/

For production configurations ensure you have configured a centralised repo such as Cloud Source Repositories, GitHub, Gitlab for use with Anthos Config manager.

Configure ACM Operator with repo

Important : You only need to do this step once per cluster

The ACM Operator must be given read access to git and configured to read from a git repository. \

It is recommended to use a deploy key to authenticate the ACM Operator with git. Using a deploy key attaches the public part of the key directly to the repo rather than to a personal user account.

Create a ssh keypair and register the public key with your git hosting provider.

# create ssh key
ssh-keygen -t rsa -N '' -b 4096 -C <git_username> -f ~/.ssh/id_rsa.acm

# add key to your ssh agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa.acm

#### add contents of public key ~/.ssh/id_rsa.acm.pub to the repo in the github account you are using for your configs 
#### github.com > Your Profile > Repositories > Settings > Deploy Keys > Add Deploy Key
 Paste in contents   

# Set write access
Select Allow write access
Click Add Key

# verify access
ssh -i /path/to/private/key [email protected]
Hi <git username>! You've successfully authenticated, but GitHub does not provide shell access.


Add the private key to a secret "git-creds" in each of your clusters.

# create secret in operator
kubectl create secret generic git-creds \
--namespace=config-management-system \
--from-file=ssh=~/.ssh/id_rsa.acm

Each cluster's ACM operator must be configured to point to the config-root in anthos-security-blueprints

Each cluster has its own config in the [setup/] directory.

  1. Create a copy of the template YAML file named mycluster-config-management.yaml in the setup/ folder of your cloned repo for each of the clusters you wish to apply any blueprints from this repo to naming the copy to reflect the name of your cluster
  2. Update each of the copied files in setup/ to include your cluster names replacing 'mycluster' with your cluster name and the syncRepo git username with yours. For example, if your github username is [email protected] change each YAML file to include
        git:
         syncRepo: [email protected]:[email protected]/csp-config-management.git

If you are using another git repo amend accordingly

  1. Remove the template file mycluster-config-management.yaml
  2. Sync the ACM Operator for your clusters by repeating the following steps for each cluster
  # Get kubeconfig credentials for your cluster
  $ gcloud container clusters get-credentials <cluster name> --zone <cluster zone>
  # Ensure kubectl is using correct context
  $ kubectl config get-context
  # Apply the configuration to your cluster
  $ kubectl apply -f setup/<cluster name>.config-management.yaml
  1. Confirm the sync was successful with nomos status

    For each cluster you should see the status set to SYNCED
    

anthos-security-blueprints's People

Contributors

grapesfrog avatar thesmiler avatar bluphy avatar kenthua avatar mrtrustor avatar pyljain avatar tobiasfrigger avatar

Watchers

 avatar

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.