Skip to content

Commit 51956b0

Browse files
authored
[kops] Add targets and README.md (#82)
* Add targets and README.md * add link to geodesic * Update docs * Add kops_non_masquerade_cidr * Add target descriptions * Update aws/kops/main.tf Co-Authored-By: osterman <[email protected]> * Update aws/kops/README.md Co-Authored-By: osterman <[email protected]> * Update aws/kops/README.md Co-Authored-By: osterman <[email protected]>
1 parent 8d9337a commit 51956b0

File tree

4 files changed

+94
-1
lines changed

4 files changed

+94
-1
lines changed

aws/kops/Makefile

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ init:
33
[ -f .terraform/terraform.tfstate ] || init-terraform
44

55
## Clean up the project
6-
clean:
6+
clean: kops/clean
77
rm -rf .terraform *.tfstate*
88

99
## Pass arguments through to terraform which require remote state
@@ -13,3 +13,39 @@ apply console destroy graph plan output providers show: init
1313
## Pass arguments through to terraform which do not require remote state
1414
get fmt validate version:
1515
terraform $@
16+
17+
## Launch a shell with the kops environment
18+
kops/shell:
19+
chamber exec kops -- bash -l
20+
21+
## Render the kops manifest template
22+
kops/build-manifest:
23+
build-kops-manifest
24+
25+
## Apply the kops manifest
26+
kops/create:
27+
kops create -f $(KOPS_MANIFEST)
28+
29+
## Create the SSH Public Key secret
30+
kops/create-secret-sshpublickey:
31+
kops create secret sshpublickey admin -i $(KOPS_SSH_PUBLIC_KEY_PATH)
32+
33+
## Show update plan for the kops cluster
34+
kops/plan:
35+
kops update cluster
36+
37+
## Apply changes to the kops cluster
38+
kops/apply:
39+
kops update cluster --yes
40+
41+
## Verify that the cluster is healthy
42+
kops/validate:
43+
kops validate cluster
44+
45+
## Export kubecfg (required to access cluster)
46+
kops/export:
47+
kops export kubecfg
48+
49+
## Delete kubecfg
50+
kops/clean:
51+
rm -f $(KUBECONFIG)

aws/kops/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Kubernetes Ops (kops)
2+
3+
This project provisions dependencies for `kops` clusters including the DNS zone, S3 bucket for state storage, SSH keypair.
4+
5+
It also writes the computed settings to SSM for usage by other modules or tools.
6+
7+
## Configuration Settings
8+
9+
10+
The minimum recommended settings are the following (`terraform.tfvars`):
11+
12+
```
13+
# EC2 Virtual Network
14+
network_cidr = "10.100.0.0/16"
15+
# Service discovery domain (should exist)
16+
zone_name = "staging.example.io"
17+
# Desired region of cluster
18+
region = "us-west-2"
19+
```
20+
21+
## Quick Start
22+
23+
This is roughly the process to get up and running. These instructions assume you're running inside of a [Geodesic shell](https://github.com/cloudposse/geodesic).
24+
1. Update the `terraform.tfvars` with [desired settings](#configuration-settings). Rebuild the container if necessary.
25+
2. Run `assume-role` to obtain a session.
26+
3. Run `make apply` to provision kops dependencies with terraform (not the cluster itself)
27+
4. Run `make kops/shell` to drop into a shell with configured environment for `kops`. Do this any time you want to interact with the cluster.
28+
5. Run `make kops/build-manifest` to compile the configuration template with current environment settings
29+
6. Run `make kops/create` to submit the cluster state manifest to the cluster state store. Note, no resources will be provisioned.
30+
7. Run `make kops/create-secret-sshpublickey` to provision the SSH public key. Note, the public key was created in the `make apply` step and requires `/secrets/tf` to be mounted. Mount this directory by running `mount -a`.
31+
8. Run `make kops/plan` to view the proposed cluster
32+
9. Run `make kops/apply` to build the cluster
33+
10. Run `make kops/validate` to view cluster status. Note, it will take ~10 minutes to come online (depending on cluster size)
34+
35+
Once the cluster is online, you can interact with it using `kubectl`.
36+
37+
To start, first run this to export `kubecfg` from the `kops` state store (required to access the cluster):
38+
```
39+
make kops/export
40+
```
41+
42+
Then all the standard `kubectl` commands will work (e.g. `kubectl get nodes`).
43+

aws/kops/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ resource "aws_ssm_parameter" "kops_utility_subnets" {
144144
overwrite = "true"
145145
}
146146

147+
resource "aws_ssm_parameter" "kops_non_masquerade_cidr" {
148+
name = "${format(var.chamber_parameter_name, local.chamber_service, "kops_non_masquerade_cidr")}"
149+
value = "${var.kops_non_masquerade_cidr}"
150+
description = "The CIDR range for Pod IPs"
151+
type = "String"
152+
overwrite = "true"
153+
}
154+
147155
resource "aws_ssm_parameter" "kops_availability_zones" {
148156
name = "${format(var.chamber_parameter_name, local.chamber_service, "kops_availability_zones")}"
149157
value = "${join(",", local.availability_zones)}"

aws/kops/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ variable "network_cidr" {
7474
default = "172.20.0.0/16"
7575
}
7676

77+
# Read more: <https://kubernetes.io/docs/tasks/administer-cluster/ip-masq-agent/#key-terms>
78+
variable "kops_non_masquerade_cidr" {
79+
description = "The CIDR range for Pod IPs."
80+
default = "100.64.0.0/10"
81+
}
82+
7783
variable "private_subnets_newbits" {
7884
description = "This is the new mask for the private subnet within the virtual network"
7985
default = "-1"

0 commit comments

Comments
 (0)