Skip to content

Commit

Permalink
Merge branch 'master' into remote-state
Browse files Browse the repository at this point in the history
  • Loading branch information
romanprog authored May 20, 2021
2 parents 6714db8 + 2c95851 commit b0817bb
Show file tree
Hide file tree
Showing 32 changed files with 957 additions and 302 deletions.
862 changes: 661 additions & 201 deletions LICENSE

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ VERSION = `git describe --tag --abbrev=0`
BUILD = `date +%FT%T%z`
CONFIG_PKG = "github.com/shalb/cluster.dev/pkg/config"

TLIST = `cdev project create --list-templates`

# Required for globs to work correctly
SHELL = /usr/bin/env bash

Expand All @@ -35,10 +37,19 @@ linux_arm64:
build: darwin_amd64 linux_amd64 linux_arm64
@echo version: $(VERSION)

examples:
rm -rf ./examples/*
for tmpl in $(TLIST); do \
cd examples ; \
mkdir $$tmpl ; \
cd $$tmpl && cdev project create $$tmpl ; \
cd ../ ; \
done

install:
GO111MODULE=on CGO_ENABLED=0 GOOS=$(CUR_GOOS) GOARCH=$(CUR_GOARCH) go install -ldflags "-w -s -X ${CONFIG_PKG}.Version=${VERSION} -X ${CONFIG_PKG}.BuildTimestamp=${BUILD}" ./cmd/$(BINNAME)

clean:
rm -rf $(BINDIR)/*

.PHONY: all clean
.PHONY: all clean examples
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The infrastructure templates could be based on Terraform modules, Kubernetes man
**Table of contents:**

* [Concept](#concept)
* [Principle Diagram](#principle-diagram)
* [Common Infrastructure Project Structure](#common-infrastructure-project-structure)
* [Infrastructure Reconcilation](#infrastructure-reconcilation)
* [Demo Video](#demo-video)
Expand Down Expand Up @@ -65,6 +66,10 @@ The infrastructure templates could be based on Terraform modules, Kubernetes man

## Concept

### Principle Diagram

![cdev diagram](./docs/images/cdev-base-diagram.png)

### Common Infrastructure Project Structure

```bash
Expand Down
70 changes: 53 additions & 17 deletions docs/get-sample-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,28 @@ cdev uses [project templates](https://cluster.dev/template-development/) to gene

```bash
git clone https://github.com/shalb/cdev-aws-k3s.git
cd examples/
cd cdev-aws-k3s/examples/
```

3. Edit variables in the example's files, if necessary.
3. Edit variables in the example's files, if necessary:
4. Run `cdev plan`.
* project.yaml - main project config. Sets common global variables for current project such as organization, region, state bucket name etc. See [project configuration docs](https://cluster.dev/project-configuration/#project).
5. Run `cdev apply`.
* backend(s).yaml - configures backend for cdev states (including Terraform states). Uses variables from project.yaml. See [backend docs](https://cluster.dev/project-configuration/#backends).
6. You can also use [code generator](https://cluster.dev/quick-start/) to create the same example.
* infrastructure.yaml - describes infrastructure configuration. See [infrastructure docs](https://cluster.dev/project-configuration/#infrastructure).
4. Run `cdev plan`
5. Run `cdev apply` . We highly recommend to run `cdev apply` in a debug mode so that you could see cdev logging in the output: `cdev apply -l debug`
6. After `cdev apply` is successfully executed, in the output you will see the ArgoCD URL of your cluster. Sign in to the console to check whether ArgoCD is up and running and the template has been deployed correctly. To sign in, use the "admin" login and the bcrypted password that you have generated for the infrastructure.yaml.
7. Displayed in the output will be also a command on how to get kubeconfig and connect to your Kubernetes cluster.
8. Shut down the cluster with the command `cdev destroy`
9. Alternatively, you can also use [code generator](https://cluster.dev/quick-start/) to create the same example.
## AWS-EKS
Expand Down Expand Up @@ -95,16 +107,28 @@ cdev uses [project templates](https://cluster.dev/template-development/) to gene
```bash
git clone https://github.com/shalb/cdev-aws-eks.git
cd examples/
cd cdev-aws-eks/examples/
```
3. Edit variables in the example's files, if necessary.
3. Edit variables in the example's files, if necessary:

* project.yaml - main project config. Sets common global variables for current project such as organization, region, state bucket name etc. See [project configuration docs](https://cluster.dev/project-configuration/#project).

* backend(s).yaml - configures backend for cdev states (including Terraform states). Uses variables from project.yaml. See [backend docs](https://cluster.dev/project-configuration/#backends).

* infrastructure.yaml - describes infrastructure configuration. See [infrastructure docs](https://cluster.dev/project-configuration/#infrastructure).

4. Run `cdev plan`

4. Run `cdev plan`.
5. Run `cdev apply` . We highly recommend to run `cdev apply` in a debug mode so that you could see cdev logging in the output: `cdev apply -l debug`

5. Run `cdev apply`.
6. After `cdev apply` is successfully executed, in the output you will see the ArgoCD URL of your cluster. Sign in to the console to check whether ArgoCD is up and running and the template has been deployed correctly. To sign in, use the "admin" login and the bcrypted password that you have generated for the infrastructure.yaml.

6. You can also use [code generator](https://cluster.dev/quick-start/) to create the same example.
7. Displayed in the output will be also a command on how to get kubeconfig and connect to your Kubernetes cluster.

8. Shut down the cluster with the command `cdev destroy`

9. Alternatively, you can also use [code generator](https://cluster.dev/quick-start/) to create the same example.

## DO-k8s

Expand All @@ -115,7 +139,7 @@ cdev uses [project templates](https://cluster.dev/template-development/) to gene
* cert-manager
* argocd

## Prerequisites
### Prerequisites

1. Terraform version 13+.

Expand All @@ -125,21 +149,33 @@ cdev uses [project templates](https://cluster.dev/template-development/) to gene

4. [cdev installed](https://cluster.dev/installation/).

## Quick Start
### Quick Start

1. [Configure access to DO](https://cluster.dev/digital-ocean-cloud-provider/) and export required variables.

2. Clone example project:

```bash
git clone https://github.com/shalb/cdev-do-k8s.git
cd examples/
cd cdev-do-k8s/examples/
```

3. Edit variables in the example's files, if necessary.
3. Edit variables in the example's files, if necessary:
* project.yaml - main project config. Sets common global variables for current project such as organization, region, state bucket name etc. See [project configuration docs](https://cluster.dev/project-configuration/#project).
* backend(s).yaml - configures backend for cdev states (including Terraform states). Uses variables from project.yaml. See [backend docs](https://cluster.dev/project-configuration/#backends).
* infrastructure.yaml - describes infrastructure configuration. See [infrastructure docs](https://cluster.dev/project-configuration/#infrastructure).
4. Run `cdev plan`
5. Run `cdev apply` . We highly recommend to run `cdev apply` in a debug mode so that you could see cdev logging in the output: `cdev apply -l debug`
6. After `cdev apply` is successfully executed, in the output you will see the ArgoCD URL of your cluster. Sign in to the console to check whether ArgoCD is up and running and the template has been deployed correctly. To sign in, use the "admin" login and the bcrypted password that you have generated for the infrastructure.yaml.
4. Run `cdev plan`.
7. Displayed in the output will be also a command on how to get kubeconfig and connect to your Kubernetes cluster.
5. Run `cdev apply`.
8. Shut down the cluster with the command `cdev destroy`
6. You can also use [code generator](https://cluster.dev/quick-start/) to create the same example.
9. Alternatively, you can also use [code generator](https://cluster.dev/quick-start/) to create the same example.
Binary file added docs/images/cdev-base-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Cluster.dev is an open-source tool designed to manage Cloud Native Infrastructur

The infrastructure templates could be based on Terraform modules, Kubernetes manifests, Shell scripts, Helm charts, Kustomize and ArgoCD/Flux applications, OPA policies etc. Cluster.dev sticks those components together so that you could deploy, test and distribute a whole set of components with pinned versions.

## Principle Diagram

![cdev diagram](./images/cdev-base-diagram.png)

## Quick Preview

![demo video cdev](./images/demo.gif)
Expand Down
10 changes: 9 additions & 1 deletion docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ This guide explains how to quickly create and deploy your first project using co

## Superquick start

If you are in hurry, this option is just for you! Just type ```cdev project create``` and specify the [template type](https://cluster.dev/project-configuration/#templates), for example:
If you are in hurry, this option is just for you! Just type ```cdev project create``` and specify the [template type](https://cluster.dev/project-configuration/#templates):

```bash
cdev project create aws-k3s
```

```bash
cdev project create aws-eks
```

```bash
cdev project create do-k8s
```

For the extended menu, run ```cdev project create --interactive``` and follow the tips below.

## Creating project workflow
Expand Down
6 changes: 6 additions & 0 deletions examples/aws-eks/backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: aws-backend
kind: Backend
provider: s3
spec:
bucket: {{ .project.variables.state_bucket_name }}
region: {{ .project.variables.region }}
37 changes: 37 additions & 0 deletions examples/aws-eks/infra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: eks-demo
template: https://github.com/shalb/cdev-aws-eks?ref=v0.1.6
kind: Infrastructure
backend: aws-backend
variables:
region: {{ .project.variables.region }}
organization: {{ .project.variables.organization }}
domain: cluster.dev
instance_type: "t3.medium"
eks_version: "1.19"
# If you want to use existing VPC and subnets, uncomment the options below and set correct VPC ID and the subnets IDs.
# Otherwise, the new VPC and subnets will be created automatically.
# vpc_id: "vpc-5ecf1234"
# public_subnets:
# - "subnet-d775f0bd"
# - "subnet-6696651a"
env: "dev"
azs:
- "{{ .project.variables.region }}a"
- "{{ .project.variables.region }}b"
default_node_pool:
- name: "spot-group"
instance_type: "t3.medium"
public_ip: true
override_instance_types:
- "t3a.medium"
- "t3.small"
spot_allocation_strategy: "lowest-price"
asg_desired_capacity: 2
asg_max_size: 4
asg_min_size: 2
root_volume_size: 50
kubelet_extra_args: "--node-labels=node.kubernetes.io/lifecycle=spot"
spot_instance_pools: 10
on_demand_base_capacity: 0
on_demand_percentage_above_base_capacity: 0
argocdServerAdminPassword: "$2a$10$1buVsK9yv0Al1oJlLmABeeRxYsArdlT2QPdNRqaZwiuYztj9JUDmu" # This bcrypted "password" is for testing only. Make sure to change it! To bcrypt your own password, use this online tool: https://www.browserling.com/tools/bcrypt
7 changes: 7 additions & 0 deletions examples/aws-eks/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: demo-project
kind: Project
variables:
organization: my-organization
region: eu-central-1
state_bucket_name: cdev-state

6 changes: 6 additions & 0 deletions examples/aws-k3s/backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: aws-backend
kind: Backend
provider: s3
spec:
bucket: {{ .project.variables.state_bucket_name }}
region: {{ .project.variables.region }}
13 changes: 3 additions & 10 deletions ...lates/project/aws-k3s/data/dev-infra.yaml → examples/aws-k3s/infra.yaml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
name: aws-backend
kind: Backend
provider: s3
spec:
bucket: {{ .project.variables.state_bucket_name }}
region: {{ .project.variables.region }}
---
name: my-k3s-cluster
template: https://github.com/shalb/cdev-aws-k3s?ref=v0.0.1-rc2
template: https://github.com/shalb/cdev-aws-k3s?ref=v0.0.2
kind: Infrastructure
backend: aws-backend
variables:
Expand All @@ -16,7 +9,7 @@ variables:
domain: cluster.dev
instance_type: "t3.medium"
k3s_version: "1.20.5+k3s1"
# If you want to use existents VPC and subnets, uncomment options below, and set correct VPC id and subnets ids.
# If you want to use existing VPC and subnets, uncomment the options below and set correct VPC ID and the subnets IDs.
# Otherwise, the new VPC and subnets will be created automatically.
# vpc_id: "vpc-*****"
# public_subnets:
Expand All @@ -34,4 +27,4 @@ variables:
min_size: 2
max_size: 3
instance_type: "t3.medium"
argocdServerAdminPassword: "$2a$10$1buVsK9yv0Al1oJlLmABeeRxYsArdlT2QPdNRqaZwiuYztj9JUDmu" # This is bcrypted "password" for test only. Change this. For bcrypt your own password you could use this online tool: https://www.browserling.com/tools/bcrypt
argocdServerAdminPassword: "$2a$10$1buVsK9yv0Al1oJlLmABeeRxYsArdlT2QPdNRqaZwiuYztj9JUDmu" # This bcrypted "password" is for testing only. Make sure to change it! To bcrypt your own password, use this online tool: https://www.browserling.com/tools/bcrypt
7 changes: 7 additions & 0 deletions examples/aws-k3s/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: demo-project
kind: Project
variables:
organization: my-organization
region: eu-central-1
state_bucket_name: cdev-state

20 changes: 0 additions & 20 deletions examples/aws_k3s/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions examples/aws_k3s/project.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions examples/do-k8s/backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: do-backend
kind: Backend
provider: do
spec:
bucket: {{ .project.variables.bucket_name }}
region: {{ .project.variables.region }}
access_key: {{ reqEnv "SPACES_ACCESS_KEY_ID" }}
secret_key: {{ reqEnv "SPACES_SECRET_ACCESS_KEY" }}
15 changes: 3 additions & 12 deletions ...t/ui/templates/project/do/data/infra.yaml → examples/do-k8s/infra.yaml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
name: do-backend
kind: Backend
provider: do
spec:
bucket: {{ .project.variables.bucket_name }}
region: {{ .project.variables.region }}
access_key: {{ reqEnv "SPACES_ACCESS_KEY_ID" }}
secret_key: {{ reqEnv "SPACES_SECRET_ACCESS_KEY" }}
---
name: prod_kubernetes
template: https://github.com/shalb/cdev-do-k8s
template: https://github.com/shalb/cdev-do-k8s?ref=v0.0.1
kind: Infrastructure
backend: do-backend
variables:
Expand All @@ -25,5 +16,5 @@ variables:
auto_scale: true
node_type: "s-1vcpu-2gb"
k8s_version: "1.19"
domain: /{ .domain }/ # You should create dns zone in DigitalOcean domains.
argo_password: "$2y$12$r474GzwwJ.pskdhS.FAM2uc/OOJL0sHrv6pcdSlm1.sGiQdrhX.Xu" # bcrypted "password"
domain: cluster.dev # You should create a DNS zone in DigitalOcean domains.
argo_password: "$2y$12$r474GzwwJ.pskdhS.FAM2uc/OOJL0sHrv6pcdSlm1.sGiQdrhX.Xu" # This bcrypted "password" is for testing only. Make sure to change it! To bcrypt your own password, use this online tool: https://www.browserling.com/tools/bcrypt
7 changes: 7 additions & 0 deletions examples/do-k8s/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: demo-project
kind: Project
variables:
organization: my-organization
region: ams3
bucket_name: cdev-state

6 changes: 0 additions & 6 deletions examples/do_k8s/project.yaml

This file was deleted.

Loading

0 comments on commit b0817bb

Please sign in to comment.