Skip to content

Commit

Permalink
Merge pull request #3 from shalb/update-to-cdev-6
Browse files Browse the repository at this point in the history
update to cli 0.6.1
  • Loading branch information
romanprog authored Dec 30, 2021
2 parents fea3824 + 2f330b8 commit f40d388
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .cdev-metadata/generator/minimal/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ options:
- name: name
description: Project name
regex: "^[a-zA-Z][a-zA-Z_0-9\\-]{0,32}$"
default: "demo-project"
default: "cdev-demo"
- name: organization
description: Organization name
regex: "^[a-zA-Z][a-zA-Z_0-9\\-]{0,64}$"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: my-k3s-cluster
template: https://github.com/shalb/cdev-aws-k3s?ref=master
template: https://github.com/shalb/cdev-aws-k3s?ref=v0.1.0
kind: Stack
backend: aws-backend
variables:
bucket: {{ .project.variables.state_bucket_name }}
region: {{ .project.variables.region }}
organization: {{ .project.variables.organization }}
cluster_name: /{ .name }/
domain: cluster.dev
instance_type: "t3.medium"
instance_type: "t3a.medium"
k3s_version: "1.20.5+k3s1"
# 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.
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ The resources to be created:
## Quick Start

1. [Configure access to AWS](https://docs.cluster.dev/examples-aws-eks/#authentication) and export required variables.
2. Clone example project:
2. In empty dir: use cdev generator to create project from this repo:
```
git clone https://github.com/shalb/cdev-aws-k3s.git
cd examples/
cdev project create https://github.com/shalb/cdev-aws-k3s
```
3. Edit variables in the example's files, if necessary.
Expand Down
86 changes: 37 additions & 49 deletions aws-k3s.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{{- $createVpcCIDR := "10.8.0.0/18" -}}
{{- $azs_count := len .variables.azs -}}
_: &getKubeconfig "export KUBECONFIG=./kubeconfig_{{ .name }} && aws s3 cp s3://{{ .variables.bucket }}/{{ .name }}/kubeconfig ./kubeconfig_{{ .name }}"
_: &getKubeconfig "export KUBECONFIG=./kubeconfig_{{ .variables.cluster_name }} && aws s3 cp s3://{{ .variables.bucket }}/{{ .variables.cluster_name }}/kubeconfig ./kubeconfig_{{ .variables.cluster_name }}"
_p: &provider_aws
- aws:
region: {{ .variables.region }}


name: aws-k3s
kind: StackTemplate
cliVersion: ">=0.6.1"
units:
-
name: aws_key_pair
Expand All @@ -24,7 +25,7 @@ units:
source: github.com/shalb/cluster.dev-domain?ref=0.1.0
inputs:
region: {{ .variables.region }}
cluster_name: {{ .name }}
cluster_name: {{ .variables.cluster_name }}
cluster_domain: {{ .variables.domain }}
zone_delegation: {{ if eq .variables.domain "cluster.dev" }}true{{ else }}false{{ end }}
{{- if not .variables.vpc_id }}
Expand All @@ -35,7 +36,7 @@ units:
source: terraform-aws-modules/vpc/aws
version: "2.70.0"
inputs:
name: {{ .name }}
name: {{ .variables.cluster_name }}
cidr: {{ $createVpcCIDR }}
public_subnets:
{{- range $index, $_ := .variables.azs }}
Expand All @@ -53,7 +54,7 @@ units:
source: ./ext-dns-iam
providers: *provider_aws
inputs:
name: {{ .name }}-test
name: {{ .variables.cluster_name }}-test
domain: {{ remoteState "this.route53.zone_id" }}
-
name: k3s
Expand All @@ -62,8 +63,9 @@ units:
pre_hook:
command: *getKubeconfig
on_apply: false
on_destroy: true
inputs:
cluster_name: {{ .name }}
cluster_name: {{ .variables.cluster_name }}
extra_args:
- "--disable traefik"
domain: {{ remoteState "this.route53.domain" }}
Expand All @@ -83,22 +85,30 @@ units:
worker_iam_policies:
- {{ remoteState "this.ext-dns-iam.arn" }}
enable_asg_rolling_auto_update: true
-
name: kubeconfig
type: shell
force_apply: true
depends_on: this.k3s
apply:
commands:
- aws s3 cp s3://{{ .variables.bucket }}/{{ .variables.cluster_name }}/kubeconfig /tmp/kubeconfig_{{ .variables.cluster_name }}
- echo "kubeconfig_base64=$(cat /tmp/kubeconfig_{{ .variables.cluster_name }} | base64 -w 0)"
- echo "kubeconfig_path=/tmp/kubeconfig_{{ .variables.cluster_name }}"
outputs:
type: separator
separator: "="
-
name: cert-manager
type: helm
source:
repository: "https://charts.jetstack.io"
chart: "cert-manager"
version: "v1.2.0"
kubeconfig: ./kubeconfig_{{ .name }}
depends_on: this.k3s
kubeconfig: {{ output "this.kubeconfig.kubeconfig_path" }}
additional_options:
namespace: "cert-manager"
create_namespace: true
pre_hook:
command: *getKubeconfig
on_destroy: true
on_plan: true
inputs:
installCRDs: true
webhook.enabled: false
Expand All @@ -109,31 +119,21 @@ units:
serviceAccount.create: true
-
name: cert-manager-issuer
type: kubernetes
source: ./cert-manager/
provider_version: "0.2.1"
kubeconfig: ./kubeconfig_{{ .name }}
type: k8s-manifest
path: ./cert-manager/issuer.yaml
kubeconfig: {{ output "this.kubeconfig.kubeconfig_path" }}
depends_on: this.cert-manager
pre_hook:
command: *getKubeconfig
on_destroy: true
on_plan: true
-
name: ingress-nginx
type: helm
source:
repository: "https://kubernetes.github.io/ingress-nginx"
chart: "ingress-nginx"
version: "3.21.0"
kubeconfig: ./kubeconfig_{{ .name }}
depends_on: this.k3s
kubeconfig: {{ output "this.kubeconfig.kubeconfig_path" }}
additional_options:
namespace: "ingress-nginx"
create_namespace: true
pre_hook:
command: *getKubeconfig
on_destroy: true
on_plan: true
inputs:
service.type: LoadBalancer
controller.admissionWebhooks.enabled: false
Expand All @@ -145,14 +145,9 @@ units:
repository: "https://kubernetes-sigs.github.io/aws-ebs-csi-driver"
chart: "aws-ebs-csi-driver"
version: "0.9.14"
kubeconfig: ./kubeconfig_{{ .name }}
depends_on: this.k3s
kubeconfig: {{ output "this.kubeconfig.kubeconfig_path" }}
additional_options:
namespace: "kube-system"
pre_hook:
command: *getKubeconfig
on_destroy: true
on_plan: true
values:
- file: ./csi/values.yaml
apply_template: false
Expand All @@ -163,51 +158,44 @@ units:
repository: "https://argoproj.github.io/argo-helm"
chart: "argo-cd"
version: "2.11.0"
pre_hook:
command: *getKubeconfig
on_destroy: true
kubeconfig: ./kubeconfig_{{ .name }}
kubeconfig: {{ output "this.kubeconfig.kubeconfig_path" }}
depends_on: this.cert-manager-issuer
additional_options:
namespace: "argocd"
create_namespace: true
inputs:
global.image.tag: v1.8.3
service.type: LoadBalancer
server.certificate.domain: argocd.{{ .name }}.{{ .variables.domain }}
server.certificate.domain: argocd.{{ .variables.cluster_name }}.{{ .variables.domain }}
server.certificate.enabled: true
server.certificate.issuer.name: letsencrypt-prod
server.certificate.issuer.kind: ClusterIssuer
server.ingress.enabled: true
server.ingress.tls[0].secretName: argocd-secret
server.ingress.hosts[0]: argocd.{{ .name }}.{{ .variables.domain }}
server.ingress.tls[0].hosts[0]: argocd.{{ .name }}.{{ .variables.domain }}
server.ingress.hosts[0]: argocd.{{ .variables.cluster_name }}.{{ .variables.domain }}
server.ingress.tls[0].hosts[0]: argocd.{{ .variables.cluster_name }}.{{ .variables.domain }}
server.ingress.annotations.cert-manager\.io/cluster-issuer: letsencrypt-prod
server.ingress.annotations.kubernetes\.io/ingress.class: nginx
server.ingress.annotations.kubernetes\.io/tls-acme: "true"
server.ingress.annotations.nginx\.ingress\.kubernetes\.io/ssl-passthrough: "true"
server.ingress.annotations.nginx\.ingress\.kubernetes\.io/backend-protocol: "HTTPS"
server.config.url: https://argocd.{{ .name }}.{{ .variables.domain }}
server.config.url: https://argocd.{{ .variables.cluster_name }}.{{ .variables.domain }}
configs.secret.argocdServerAdminPassword: {{ .variables.argocdServerAdminPassword }}
configs.secret.argocdServerAdminPasswordMtime: "2021-01-01T00:00:00Z"
-
name: argocd_apps
type: kubernetes
provider_version: "0.2.1"
source: ./argocd-apps/
pre_hook:
command: *getKubeconfig
on_destroy: true
on_plan: true
kubeconfig: ./kubeconfig_{{ .name }}
type: k8s-manifest
path: ./argocd-apps/
kubeconfig: {{ output "this.kubeconfig.kubeconfig_path" }}
depends_on: this.argocd
-
name: print_outputs
type: printer
depends_on: this.argocd_apps
inputs:
cluster_name: {{ .name }}
cluster_name: {{ .variables.cluster_name }}
region: {{ .variables.region }}
kubeconfig: *getKubeconfig
k3s_version: {{ .variables.k3s_version }}
argocd_url: https://argocd.{{ .name }}.{{ .variables.domain }}
argocd_url: https://argocd.{{ .variables.cluster_name }}.{{ .variables.domain }}

9 changes: 9 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
1. [Configure access to AWS](https://docs.cluster.dev/examples-aws-eks/#authentication) and export required variables.
2. In empty dir: use cdev generator to create project from this repo:
```
cdev project create https://github.com/shalb/cdev-aws-k3s
```
3. Edit variables in the example's files, if necessary.
4. Run `cdev plan`
5. Run `cdev apply`
6 changes: 0 additions & 6 deletions examples/backend.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions examples/dev-infra.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions examples/project.yaml

This file was deleted.

0 comments on commit f40d388

Please sign in to comment.