Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#339 from akutz/feature/network-ex
Browse files Browse the repository at this point in the history
Enhances networking to support cloud-init v2 network config, cleanup, bug fixes
  • Loading branch information
k8s-ci-robot authored Jun 24, 2019
2 parents 013bdcf + a88ebd1 commit c3d8e84
Show file tree
Hide file tree
Showing 49 changed files with 2,526 additions and 1,142 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ bin/

# ignore generated yaml in out/
out/

# Ignore the kubeconfig file generated by clusterctl
/kubeconfig
62 changes: 20 additions & 42 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,12 @@ clusterctl: fmt vet
go build -o bin/clusterctl ./cmd/clusterctl

clusterctl-in-docker:
docker run -v $(CWD):/go/src/sigs.k8s.io/cluster-api-provider-vsphere \
docker run --rm -v $(CWD):/go/src/sigs.k8s.io/cluster-api-provider-vsphere \
-w /go/src/sigs.k8s.io/cluster-api-provider-vsphere \
-e GOOS -e GOHOSTOS golang:1.12 \
bash -c "go build -o bin/clusterctl ./cmd/clusterctl"
go build -o bin/clusterctl ./cmd/clusterctl
.PHONY: clusterctl-in-docker

# Build the clusterctl-tools container used for generating example clusterctl yaml
clusterctl-tools:
[ -n "$(shell docker images -q clusterctl-tools)" ] || docker build -t clusterctl-tools -f $(CWD)/cmd/clusterctl/examples/tools/Dockerfile .
.PHONY: clusterctl-tools

# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet
go run ./cmd/manager/main.go
Expand All @@ -74,11 +69,15 @@ manifests:
hack/update-generated.sh crd rbac

# Run go fmt against code
fmt:
fmt: | generate
ifneq (,$(strip $(shell command -v goformat 2>/dev/null)))
goformat -s -w ./pkg ./cmd
else
go fmt ./pkg/... ./cmd/...
endif

# Run go vet against code
vet:
vet: | generate
go vet ./pkg/... ./cmd/...

# Generate code
Expand All @@ -100,34 +99,21 @@ vendor:
cp -rf --no-preserve=mode "$${_src}" "$${_dst}"
.PHONY: vendor

# GENERATE_YAML_ENV_VARS is the list of all environment variables expected by generate-yaml.sh
# to build example manifests for clusterctl. The list of environment variables here should contain
# the environment variables expected in generate-yaml.sh
GENERATE_YAML_ENV_VARS := -e CLUSTER_NAME -e SERVICE_CIDR -e CLUSTER_CIDR -e CAPV_YAML_VALIDATION \
-e VSPHERE_USER -e VSPHERE_PASSWORD -e VSPHERE_SERVER -e VSPHERE_DATACENTER \
-e VSPHERE_DATASTORE -e VSPHERE_NETWORK -e VSPHERE_RESOURCE_POOL -e VSPHERE_FOLDER \
-e VSPHERE_TEMPLATE -e VSPHERE_DISK -e VSPHERE_DISK_SIZE_GB -e CAPV_MANAGER_IMAGE \
-e KUBERNETES_VERSION

####################################
# DEVELOPMENT Build and Push targets
####################################

# Create YAML file for deployment
dev-yaml: | clusterctl-tools
docker run -v $(CWD):/go/src/sigs.k8s.io/cluster-api-provider-vsphere \
-w /go/src/sigs.k8s.io/cluster-api-provider-vsphere \
-u $$(id -u):$$(id -g) \
$(GENERATE_YAML_ENV_VARS) clusterctl-tools \
bash -c "CAPV_MANAGER_IMAGE=${DEV_IMG} cmd/clusterctl/examples/vsphere/generate-yaml.sh"
dev-yaml:
CAPV_MANAGER_IMAGE=$(DEV_IMG) hack/generate-yaml.sh

# Build the docker image
dev-build: #test
docker build . -t ${DEV_IMG}
docker build . -t $(DEV_IMG)

# Push the docker image
dev-push:
docker push ${DEV_IMG}
docker push $(DEV_IMG)

.PHONY: dev-yaml dev-build dev-push

Expand All @@ -136,22 +122,18 @@ dev-push:
###################################

# Create YAML file for deployment
prod-yaml: | clusterctl-tools
docker run -v $(CWD):/go/src/sigs.k8s.io/cluster-api-provider-vsphere \
-w /go/src/sigs.k8s.io/cluster-api-provider-vsphere \
-u $$(id -u):$$(id -g) \
$(GENERATE_YAML_ENV_VARS) clusterctl-tools \
bash -c "CAPV_MANAGER_IMAGE=${PRODUCTION_IMG} cmd/clusterctl/examples/vsphere/generate-yaml.sh"
prod-yaml:
CAPV_MANAGER_IMAGE=$(PRODUCTION_IMG) hack/generate-yaml.sh

# Build the docker image
prod-build: test
docker build . -t ${PRODUCTION_IMG}
docker build . -t $(PRODUCTION_IMG)

# Push the docker image
prod-push:
@echo "logging into gcr.io registry with key file"
@docker login -u _json_key --password-stdin gcr.io <"$(GCR_KEY_FILE)"
docker push ${PRODUCTION_IMG}
docker push $(PRODUCTION_IMG)

.PHONY: prod-yaml prod-build prod-push

Expand All @@ -160,12 +142,8 @@ prod-push:
###################################

# Create YAML file for deployment into CI
ci-yaml: | clusterctl-tools
docker run -v $(CWD):/go/src/sigs.k8s.io/cluster-api-provider-vsphere \
-w /go/src/sigs.k8s.io/cluster-api-provider-vsphere \
-u $$(id -u):$$(id -g) \
$(GENERATE_YAML_ENV_VARS) clusterctl-tools \
bash -c "CAPV_MANAGER_IMAGE=${CI_IMG}:${VERSION} cmd/clusterctl/examples/vsphere/generate-yaml.sh"
ci-yaml:
CAPV_MANAGER_IMAGE=$(CI_IMG) hack/generate-yaml.sh

ci-image: generate fmt vet manifests
docker build . -t "$(CI_IMG):$(VERSION)"
Expand All @@ -186,10 +164,10 @@ ci-push: ci-image
################################################################################

# The default build target
build: clusterctl manager
build: manager clusterctl
.PHONY: build

# The default test target
test: generate fmt vet manifests
test: build manifests
go test ./pkg/... ./cmd/... -coverprofile cover.out
.PHONY: test
15 changes: 0 additions & 15 deletions cmd/clusterctl/examples/tools/Dockerfile

This file was deleted.

8 changes: 4 additions & 4 deletions cmd/clusterctl/examples/vsphere/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
## Generation
For convenience, a generation script which populates templates where possible.

1. Run the generation script. This wil produce ```provider-components.yaml```
1. Run the generation script. This wil produce ```./out/provider-components.yaml```
```shell
./hack/generate-yaml.sh
```
./generate-yaml.sh
```
2. To define the master machine, copy `machines.yaml.template` to `machines.yaml` and
1. To define the master machine, copy `machines.yaml.template` to `machines.yaml` and
manually edit `machineSpec`.

3. To define nodes, copy `machineset.yaml.template` to `machineset.yaml` and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ spec:
spec:
containers:
# Change the value of image field below to your controller image URL
- image: ${CAPV_MANAGER_IMAGE}
- image: "${CAPV_MANAGER_IMAGE}"
name: manager
28 changes: 14 additions & 14 deletions cmd/clusterctl/examples/vsphere/cluster.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ kind: Cluster
metadata:
name: ${CLUSTER_NAME}
spec:
clusterNetwork:
services:
cidrBlocks: ["${SERVICE_CIDR}"]
pods:
cidrBlocks: ["${CLUSTER_CIDR}"]
serviceDomain: "cluster.local"
providerSpec:
value:
apiVersion: "vsphereproviderconfig/v1alpha1"
kind: "VsphereClusterProviderConfig"
vsphereUser: "${VSPHERE_USER}"
vspherePassword: "${VSPHERE_PASSWORD}"
vsphereServer: "${VSPHERE_SERVER}"
vsphereCredentialSecret: ""
clusterNetwork:
services:
cidrBlocks: ["${SERVICE_CIDR}"]
pods:
cidrBlocks: ["${CLUSTER_CIDR}"]
serviceDomain: "cluster.local"
providerSpec:
value:
apiVersion: "vsphereproviderconfig/v1alpha1"
kind: "VsphereClusterProviderConfig"
vsphereUser: "${VSPHERE_USER}"
vspherePassword: "${VSPHERE_PASSWORD}"
vsphereServer: "${VSPHERE_SERVER}"
vsphereCredentialSecret: ""
Loading

0 comments on commit c3d8e84

Please sign in to comment.