Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main project readme #79

Merged
merged 22 commits into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4ec90d5
# This is a combination of 99 commits.
erikschlegel Apr 13, 2019
a656327
resolving merge conflicts for squash
erikschlegel Apr 25, 2019
31cff7a
squashing commits and slimming down the build image
erikschlegel Apr 25, 2019
ba30507
squashing commits and slimming down the build image
erikschlegel Apr 25, 2019
bfca01a
removing go* path from azure devops pipeline as we removed go mods
erikschlegel Apr 25, 2019
32639c8
refactoring our azure devops pipeline so it's aligned with the local …
erikschlegel Apr 25, 2019
c5f610e
fixing azure devops pipeline bug
erikschlegel Apr 25, 2019
adaf6aa
fixing base image build variable reference bug
erikschlegel Apr 25, 2019
6cb6fd3
Addressing nick's PR comments
erikschlegel Apr 25, 2019
0159da6
Merge branch 'master' of https://github.com/Microsoft/cobalt into eri…
erikschlegel Apr 25, 2019
ff9a3ac
resolving issue with failed builds after completing branches merges
erikschlegel Apr 26, 2019
fc2fb58
addressing a bug where test harness directory changes were not gettin…
erikschlegel Apr 26, 2019
86c8fc4
removing local echo statement
erikschlegel Apr 26, 2019
257c508
Adding directory exists check and app service container command variable
erikschlegel Apr 26, 2019
ba2d08a
addressing nick's PR comments
erikschlegel Apr 26, 2019
1426db8
adding git diff extension whitelist filter
erikschlegel Apr 26, 2019
d6b4002
Overhauling main project readme
erikschlegel Apr 27, 2019
50792e3
Adding james to the readme
erikschlegel Apr 27, 2019
084d18f
Merge branch 'master' of https://github.com/Microsoft/cobalt into eri…
erikschlegel Apr 27, 2019
873a811
Update README.md
erikschlegel Apr 28, 2019
3c58e88
Updating readme from the test-harness directory
erikschlegel Apr 29, 2019
7f76a66
rebase
erikschlegel Apr 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Overhauling main project readme
  • Loading branch information
erikschlegel committed Apr 27, 2019
commit d6b4002948e965befc703d31b6853e4ce1f3f666
154 changes: 63 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,120 +1,90 @@
[![Build Status](https://dev.azure.com/csedallascrew/project-cobalt/_apis/build/status/Microsoft.cobalt?branchName=master)](https://dev.azure.com/csedallascrew/project-cobalt/_build/latest?definitionId=2&branchName=master)
# Cobalt

# Setup
[![Build Status](https://dev.azure.com/csedallascrew/project-cobalt/_apis/build/status/Microsoft.cobalt?branchName=master)](https://dev.azure.com/csedallascrew/project-cobalt/_build/latest?definitionId=2&branchName=master)

The artifacts used to deploy this project include bash scripts and Terraform templates. The sections below provide guidance to deploy this project into your Azure environment.
This project is an attempt to combine and share best practices when building production ready [cloud native](https://www.cncf.io/) managed service solutions. Cobalt's infrastructure turn-key starter [templates](./infra/providers/) are based on real world engagements with enterprise customers.

> The setup instructions below assume the following requirements:
> - bash v4.0 (or newer)
> - **NOTE FOR MAC!** The default version of bash installed on Mac is older than 4.0. Be sure to update bash using brew before executing the script. Instructions to update bash can be found [here](http://macappstore.org/bash/).
> - Terraform v0.11.13 (or newer)
This project puts a focus on infrastructure scalability, security, automated testing and deployment repeatability and most importantly, developer experience. Cobalt's intended audience is for developers. Feedback and suggestions are encouraged through issue requests. We welcome contributions across any one of the major cloud providers.

Cobalt is a joint collaboration with project [Bedrock](https://github.com/Microsoft/bedrock). One of the project goals is predictlably create, change and improve infrastructure.

## Setup the Azure Container Registry and Service Principals
This project offers a set of continuous integration pipelines responsible for testing and deploying templated environments to cloud provider(s).

1. Open a bash command prompt.
2. Navigate to the `./setup` folder.
3. Authenticate to Azure.
``` bash
az login
```
4. Run `acr-sp-init.sh`. For example, the command below will provision an Azure Container Registry (ACR) in East US and configure the two service principals in Azure Active Directory; one with _AcrPush_ permission and another with _AcrPull_ permission scoped to the ACR. The script parameter values are used to construct the name of the resource group, ACR, and service principals.
## How Cobalt differs to Bedrock

``` bash
$ ./acr-sp-init.sh -a Cblt -l eastus -s CoreProd
```
Cobalt hosts reusable Terraform modules to scaffold managed container services like [ACI](https://docs.microsoft.com/en-us/azure/container-instances/) and [Application Services](https://docs.microsoft.com/en-us/azure/app-service/) as a couple of examples. Bedrock targets Kubernetes-based container orchestration workloads while following a [GitOps](https://medium.com/@timfpark/highly-effective-kubernetes-deployments-with-gitops-c7a0354f1446) devops flow. Cobalt templates reference Terraform modules like virtual networks, traffic manager, etc.

> Note: The script configures service principals in Azure AD and therefore requires elevated privileges. As such, it is recommended that an interactive user with permissions to configure Azure AD run the script.

### Automated Test
## About the Repository

The automated test for this setup step is in `./tests/acr-sp-init-test.sh`. It can be executed at the command line as shown below, or as part of a CI pipeline. If you don't want the test to cleanup resources, then pass the `-n` switch.
### Infrastructure as Code

``` bash
az login
Cobalt deployment environment templates are written in Terraform and can be found in the templates [folder](infra/templates). Each subfolder represents a unique deployment environment packaged with a set of Terraform scripts, overview and setup instructions, automated unit and integration tests.

# Run test and cleanup resources created.
./tests/acr-sp-init-test.sh
Each template makes use of Terraform [modules](https://www.terraform.io/docs/modules/index.html) across both Bedrock and [Cobalt](infra/modules). Cobalt's module registry is categorized by cloud provider then resource type. Each modules represents an absraction for the set of related cloud infrastructure objects that the module will manage.
```
$ tree infra
├───modules
│ └───providers
│ ├───azure
│ │ ├───api-mgmt
│ │ ├───app-gateway
│ │ ├───provider
│ │ ├───service-plan
│ │ ├───tm-endpoint-ip
│ │ ├───tm-profile
│ │ └───vnet
│ └───common
└───templates
├───azure-simple-hw
│ └───test
│ └───integration
└───backend-state-setup
```

## Setup Shared / Core Infrastructure
### Continuous Integration / Deployment + Testing

### Requirements
Cobalt Continuous Integration pipeline defintions are available in the `./devops/provider` folder. As of today, Cobalt provides a git devops worklfow [definition](devops/providers/azure-devops/templates/azure-pipelines.yml) for Azure DevOps. We welcome pipelines from other providers like Jenkins.

- Azure Subscription User (with deployment rights)
- [Terraform](https://www.terraform.io/downloads.html)
#### Azure DevOps CI Flow

### Resources
![image](https://user-images.githubusercontent.com/7635865/56855601-73383480-690f-11e9-9ec9-3f35bedb39ec.png)

The following respources will be deployed
- Azure Resource Group
This pipeline is configured to trigger new builds for each new branch commit.

### Deployment
1. Deployment credential secrets such as service principal and terraform remote state storage accounts are sourced in azure keyvault.
2. The pipeline downloads secrets from keyvault and used to resolve terraform template variables.
3. We rebuild the test harness image so we can copy the terraform template changes from the git branch over to the docker file system.
4. We then run the test harness container, which performs the following stages.
* Run a lint check on all golang test files and terraform templates.
* Executes all golang unit tests.
* Generate and validate the terraform plan.
* Apply the terraform template resource updates to the development integration deployment environment.
* Run end-to-end integration tests.
* Tear down deployed resources.
5. Update the build and PR status.
6. Begin code review once the PR status is green.

1. Authenticate using your Azure Principal or an Azure account with privileges to deploy resource groups.
### Getting Started

``` bash
$ az login
```
The easiest way to try Cobalt is to start with our [azure-simple](https://github.com/Microsoft/cobalt/tree/master/infra/templates/azure-simple-hw) template.

2. Execute the following commands:
A cobalt deployment is comprised of 3 general steps.

``` bash
$ cd ./shared
$ terraform init
$ terraform apply
```
1. You can follow these [instructions](devops/providers/azure-devops/README.md) to create an cloud-based CI pipeline definition.
2. Our cloud deployment templates provide an configurable default setup intended for a t-shirt sized environment scenario. Pick the template folder most relevant to your use-case as a starting point. Each template folder is shipped with setup instructions.
3. It's important to implement quality assurance that validates E2E functional assertions against your infrastructure resources. Each template comes pre-packaged with some basic integration and unit tests. We encourage you to define integration tests in the `test/integration` folder of your template that's specific to your use-case.
4. Follow these [instructions](test-harness/README.md) to setup your local environment.
5. Create a new local git branch and commit your changes. Run the test harness on your localhost via `./test-harness/local-run.sh`.

### Environmental Variables
## Community

To stop the command line from prompting questions use a .env file with the following environmental variables:
[Please join us on Slack](https://publicslack.com/slacks/https-bedrockco-slack-com/invites/new) for discussion and/or questions.

```
export TF_VAR_app_name=cblt
export TF_VAR_org=cse
export TF_VAR_env=dev
export TF_VAR_location=eastus
```

After saving the file set environment using:

``` bash
. .env
```
## Contributing

Alternative use the variable.tf files in the directories and add the default key on the file as shown on the example below:
We do not claim to have all the answers and would greatly appreciate your ideas and pull requests.

```
variable "location" {
type = "string"
description = "The name of the target location"
default = "eastus"
}
variable "env" {
type = "string"
description = "The short name of the target env (i.e. dev, staging, or prod)"
defailt = "dev"
}
variable "org" {
type = "string"
description = "The short name of the organization"
default = "cse"
}
variable "app_name" {
type = "string"
description = "The short name of the application"
default = "cblt"
}
```

## Setup Application Infrastructure

> Coming soon!


# Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.microsoft.com.

Expand All @@ -124,4 +94,6 @@ provided by the bot. You will only need to do this once across all repos using o

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

For project level questions, please contact [Erik Schlegel](mailto:erisch@microsoft.com).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added design-reference/devops/cobalt-devops-ci.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.