Skip to content

Commit

Permalink
Use CLUSTER_NAME instead of CLUSTER (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
osterman authored Nov 22, 2017
1 parent 792b595 commit 3453a81
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ ENV KOPS_BASE_IMAGE=kope.io/k8s-1.7-debian-jessie-amd64-hvm-ebs-2017-07-28
ENV KOPS_BASTION_PUBLIC_NAME="bastion"
ENV KOPS_PRIVATE_SUBNETS="172.20.32.0/19,172.20.64.0/19,172.20.96.0/19,172.20.128.0/19"
ENV KOPS_UTILITY_SUBNETS="172.20.0.0/22,172.20.4.0/22,172.20.8.0/22,172.20.12.0/22"
ENV KOPS_AVAILABILITY_ZONES="us-west-2a,us-west-2b,us-west-2c"
ENV KUBECONFIG=/dev/shm/kubecfg
RUN curl --fail -sSL -O https://github.com/kubernetes/kops/releases/download/${KOPS_VERSION}/kops-linux-amd64 \
&& mv kops-linux-amd64 /usr/local/bin/kops \
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ Docker can be easily installed by following the instructions for your OS:

## Quick Start

1. `export CLUSTER=test.example.com`
1. `export CLUSTER_NAME=test.example.com`

2. Create a new project

This will create a new project in your current working directory, complete with `Dockerfile` and `Makefile`.

```
docker run -e CLUSTER \
-e DOCKER_IMAGE=cloudposse/${CLUSTER} \
docker run -e CLUSTER_NAME \
-e DOCKER_IMAGE=cloudposse/${CLUSTER_NAME} \
-e DOCKER_TAG=dev \
cloudposse/geodesic:latest -c new-project | tar -xv -C .
```

2. Customize project as necessary. Edit the `Dockerfile` to reflect your settings. The files are installed to the `$CLUSTER/` folder.
2. Customize project as necessary. Edit the `Dockerfile` to reflect your settings. The files are installed to the `$CLUSTER_NAME/` folder.
```
cd $CLUSTER
cd $CLUSTER_NAME
```

3. Initialize the project
Expand All @@ -86,7 +86,7 @@ Docker can be easily installed by following the instructions for your OS:
make install
```

6. Run the shell: `/usr/local/bin/$CLUSTER`
6. Run the shell: `/usr/local/bin/$CLUSTER_NAME`

## Creating a Kops Cluster

Expand Down
18 changes: 9 additions & 9 deletions rootfs/templates/kops/default.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kops/v1alpha2
kind: Cluster
metadata:
name: {{getenv "CLUSTER"}}
name: {{getenv "CLUSTER_NAME"}}
spec:
api:
loadBalancer:
Expand All @@ -10,13 +10,13 @@ spec:
alwaysAllow: {}
channel: stable
cloudLabels:
Cluster: {{getenv "CLUSTER"}}
Cluster: {{getenv "CLUSTER_NAME"}}
cloudProvider: aws
configBase: {{getenv "KOPS_STATE_STORE" }}/{{getenv "CLUSTER"}}
configBase: {{getenv "KOPS_STATE_STORE" }}/{{getenv "CLUSTER_NAME"}}
{{if getenv "KOPS_DNS_ZONE" }}
dnsZone: {{getenv "KOPS_DNS_ZONE"}}
{{else}}
dnsZone: {{getenv "CLUSTER" | regexp.Replace "^[^.]+\\." ""}}
dnsZone: {{getenv "CLUSTER_NAME" | regexp.Replace "^[^.]+\\." ""}}
{{end}}
etcdClusters:
- etcdMembers:
Expand All @@ -36,7 +36,7 @@ spec:
kubernetesApiAccess:
- 0.0.0.0/0
kubernetesVersion: {{getenv "KUBERNETES_VERSION"}}
masterPublicName: api.{{getenv "CLUSTER"}}
masterPublicName: api.{{getenv "CLUSTER_NAME"}}
networkCIDR: 172.20.0.0/16
networking:
calico: {}
Expand All @@ -62,7 +62,7 @@ spec:
{{- end }}
topology:
bastion:
bastionPublicName: {{ getenv "KOPS_BASTION_PUBLIC_NAME"}}.{{getenv "CLUSTER"}}
bastionPublicName: {{ getenv "KOPS_BASTION_PUBLIC_NAME"}}.{{getenv "CLUSTER_NAME"}}
dns:
type: Public
masters: private
Expand All @@ -73,7 +73,7 @@ apiVersion: kops/v1alpha2
kind: InstanceGroup
metadata:
labels:
kops.k8s.io/cluster: {{getenv "CLUSTER"}}
kops.k8s.io/cluster: {{getenv "CLUSTER_NAME"}}
name: bastions
spec:
image: {{getenv "KOPS_BASE_IMAGE"}}
Expand All @@ -93,7 +93,7 @@ apiVersion: kops/v1alpha2
kind: InstanceGroup
metadata:
labels:
kops.k8s.io/cluster: {{getenv "CLUSTER"}}
kops.k8s.io/cluster: {{getenv "CLUSTER_NAME"}}
name: master-{{.}}
spec:
associatePublicIp: false
Expand All @@ -111,7 +111,7 @@ apiVersion: kops/v1alpha2
kind: InstanceGroup
metadata:
labels:
kops.k8s.io/cluster: {{getenv "CLUSTER"}}
kops.k8s.io/cluster: {{getenv "CLUSTER_NAME"}}
name: nodes
spec:
associatePublicIp: false
Expand Down
6 changes: 3 additions & 3 deletions rootfs/templates/scaffolding/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export CLUSTER ?= $(shell basename `pwd`)
export CLUSTER_NAME ?= $(shell basename `pwd`)
export DOCKER_ORG ?= {{ getenv "DOCKER_ORG" "cloudposse" }}
export DOCKER_IMAGE ?= $(DOCKER_ORG)/$(CLUSTER)
export DOCKER_IMAGE ?= $(DOCKER_ORG)/$(CLUSTER_NAME)
export DOCKER_TAG ?= dev
export DOCKER_IMAGE_NAME ?= $(DOCKER_IMAGE):$(DOCKER_TAG)
export DOCKER_BUILD_FLAGS =
Expand All @@ -22,4 +22,4 @@ install:
@docker run --rm -e DOCKER_IMAGE -e DOCKER_TAG $(DOCKER_IMAGE_NAME) | sudo bash -s $(DOCKER_TAG)

run:
$(CLUSTER)
$(CLUSTER_NAME)
6 changes: 3 additions & 3 deletions rootfs/usr/local/bin/new-project
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash
CLUSTER=${CLUSTER:-geodesic.example.org}
CLUSTER_NAME=${CLUSTER_NAME:-geodesic.example.org}
SCAFFOLDING=/templates/scaffolding/
OUTPUT=/tmp/scaffolding

rm -rf ${OUTPUT}
mkdir -p ${OUTPUT}

# Render templates
echo "Building project for ${CLUSTER}..." 1>&2
echo "Building project for ${CLUSTER_NAME}..." 1>&2
gomplate --input-dir ${SCAFFOLDING} --output-dir ${OUTPUT}

# Compress into a tarball
cd ${OUTPUT}
tar --transform="s|^./|${CLUSTER}/|" -c .
tar --transform="s|^./|${CLUSTER_NAME}/|" -c .

0 comments on commit 3453a81

Please sign in to comment.