Skip to content

Commit

Permalink
Update cluster generation tools, manifests, and instructions
Browse files Browse the repository at this point in the history
- generation script
- Makefile
- addons
- example templates
- kustomize templates
- README.md

Signed-off-by: Stephen Augustus <saugustus@vmware.com>
  • Loading branch information
tariq1890 authored and justaugustus committed Jan 29, 2019
1 parent f10df15 commit a028983
Show file tree
Hide file tree
Showing 32 changed files with 949 additions and 557 deletions.
1 change: 0 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.

# Image URL to use all building/pushing image targets
PREFIX ?= platform9
NAME = cluster-api-azure-provider-controller
TAG ?= latest
PREFIX ?= quay.io/k8s
NAME ?= cluster-api-azure-controller
TAG ?= 0.2.0-alpha.3
IMG=${PREFIX}/${NAME}:${TAG}

# Keep an existing GOPATH/GOBIN, make a private one if it is not defined
Expand Down Expand Up @@ -114,8 +114,8 @@ check: verify-boilerplate bootstrap vendor-validate lint
# Build the docker image
docker-build: test
docker build . -t ${IMG}
@echo "updating kustomize image patch file for manager resource"
sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml
#@echo "updating kustomize image patch file for manager resource"
#sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml

# Push the docker image
docker-push:
Expand All @@ -124,8 +124,8 @@ docker-push:
# Build the docker dev image
docker-build-dev: test
docker build . -t "${IMG}-dev"
@echo "updating kustomize image patch file for manager resource"
sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml
#@echo "updating kustomize image patch file for manager resource"
#sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml

# Push the docker dev image
docker-push-dev:
Expand Down
123 changes: 84 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,50 @@
# Kubernetes Cluster API Azure Provider [![Go Report Card](https://goreportcard.com/badge/sigs.k8s.io/cluster-api-provider-azure)](https://goreportcard.com/report/kubernetes-sigs/cluster-api-provider-azure)

## Getting Started
### Prerequisites
1. Install [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/).
2. Install [minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/) and a [minikube driver](https://github.com/kubernetes/minikube/blob/master/docs/drivers.md). It is recommended to use KVM2 driver for Linux and VirtualBox for MacOS.
3. Install [kustomize](https://github.com/kubernetes-sigs/kustomize/blob/master/docs/INSTALL.md).
4. Clone the Project.
```bash
git clone https://github.com/kubernetes-sigs/cluster-api-provider-azure $(go env GOPATH)/src/sigs.k8s.io/cluster-api-provider-azure
```
5. Ensure that you have the project root as your current working directory.
```bash
cd $(go env GOPATH)/src/sigs.k8s.io/cluster-api-provider-azure
```
6. Build the `clusterctl` tool.

```bash
make clusterctl
```
### Requirements

- Linux or MacOS (Windows isn't supported at the moment)
- A set of Azure credentials sufficient to bootstrap the cluster (an Azure service principal with Collaborator rights).
- [KIND]
- [kubectl]
- [kustomize]
- make
- gettext (with `envsubst` in your PATH)
- bazel

### Optional

- [Homebrew][brew] (MacOS)
- [jq]
- [Go]

[brew]: https://brew.sh/
[Go]: https://golang.org/dl/
[jq]: https://stedolan.github.io/jq/download/
[KIND]: https://sigs.k8s.io/kind
[kubectl]: https://kubernetes.io/docs/tasks/tools/install-kubectl/
[kustomize]: https://github.com/kubernetes-sigs/kustomize

### Install the project

#### Release binaries
TODO. Coming soon!

#### Building from master

Currently, you'll need to build the latest version from `master`:

```bash
# Get the latest version of cluster-api-provider-azure
go get sigs.k8s.io/cluster-api-provider-azure

# Ensure that you have the project root as your current working directory.
cd $(go env GOPATH)/src/sigs.k8s.io/cluster-api-provider-azure

# Build the `clusterctl` tool.
make clusterctl
```

### Prepare your environment
An Azure Service Principal is needed for usage by the `clusterctl` tool and for populating the controller manifests. This utilizes [environment-based authentication](https://docs.microsoft.com/en-us/go/azure/azure-sdk-go-authorization#use-environment-based-authentication). The following environment variables should be set: `AZURE_SUBSCRIPTION_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_ID` and `AZURE_CLIENT_SECRET`.
Expand All @@ -31,7 +58,7 @@ An alternative is to install [Azure CLI](https://docs.microsoft.com/en-us/cli/az

```
cd cmd/clusterctl/examples/azure
CREATE_SP=FALSE ./generate-yaml.sh # set to TRUE if creating a new Service Principal is desired
RESOURCE_GROUP=capz-test CLUSTER_NAME="capz-test-0" ./generate-yaml.sh # set CREATE_SP=TRUE if creating a new Service Principal is desired
cd ../../../..
# If CREATE_SP=TRUE
source cmd/clusterctl/examples/azure/out/credentials.sh
Expand All @@ -43,36 +70,54 @@ An alternative is to install [Azure CLI](https://docs.microsoft.com/en-us/cli/az
echo "---" >> cmd/clusterctl/examples/azure/out/provider-components.yaml
kustomize build vendor/sigs.k8s.io/cluster-api/config/default/ >> cmd/clusterctl/examples/azure/out/provider-components.yaml
```
3. Create the cluster.
Kubernetes Version >= 1.11 is required to enable CRD subresources without needing a feature gate.
3. Create the cluster.

**NOTE:** Kubernetes Version >= 1.11 is required to enable CRD subresources without needing a feature gate.

**Linux**
```bash
./bin/clusterctl create cluster --provider azure \
-m cmd/clusterctl/examples/azure/out/machines.yaml \
-c cmd/clusterctl/examples/azure/out/cluster.yaml \
-p cmd/clusterctl/examples/azure/out/provider-components.yaml \
--vm-driver kvm2 --minikube kubernetes-version=v1.12.2
```

**macOS**
```bash
./bin/clusterctl create cluster --provider azure \
-m cmd/clusterctl/examples/azure/out/machines.yaml \
-c cmd/clusterctl/examples/azure/out/cluster.yaml \
-p cmd/clusterctl/examples/azure/out/provider-components.yaml \
--vm-driver virtualbox --minikube kubernetes-version=v1.12.2
./bin/clusterctl create cluster -v 3 \
--provider azure \
--bootstrap-type kind \
-m ./cmd/clusterctl/examples/azure/out/machines.yaml \
-c ./cmd/clusterctl/examples/azure/out/cluster.yaml \
-p ./cmd/clusterctl/examples/azure/out/provider-components.yaml \
-a ./cmd/clusterctl/examples/azure/out/addons.yaml
```

Once the cluster is created successfully, you can interact with the cluster using `kubectl` and the kubeconfig downloaded by the `clusterctl` tool.

```
kubectl --kubeconfig=kubeconfig get clusters
kubectl --kubeconfig=kubeconfig get machines
export KUBECONFIG="$(kind get kubeconfig-path --name="clusterapi")"
kubectl get clusters
kubectl get machines
```

### Creating and using controller images
TODO

### Testing
TODO
Here's an example of how to build controller images, if you're interested in testing changes in the image yourself:

```bash
# Build the image.
PREFIX=quay.io/k8s \
NAME=cluster-api-azure-controller \
TAG=0.2.0-alpha.3 \
make docker-build

# Push the image.
PREFIX=quay.io/k8s \
NAME=cluster-api-azure-controller \
TAG=0.2.0-alpha.3 \
make docker-push
```

**NOTE:** In order for the created images to be used for testing, you must push them to a public container registry.

### Submitting PRs and testing

Pull requests and issues are highly encouraged!
If you're interested in submitting PRs to the project, please be sure to run some initial checks prior to submission:

```bash
make check # Runs a suite of quick scripts to check code structure
make test # Runs tests on the Go code
```
Binary file removed cmd/clusterctl/clusterctl
Binary file not shown.
27 changes: 27 additions & 0 deletions cmd/clusterctl/examples/azure/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Azure Example Files

## Contents

*.yaml files - concrete example files that can be used as is.
*.yaml.template files - template example files that need values filled in before use.

## Generation

For convenience, a generation script which populates templates based on azure configuration is provided.

1. Run the generation script.

``` shell
./generate-yaml.sh
```

If the yaml file already exists, you will see an error like the one below:

``` shell
$ ./generate-yaml.sh
File provider-components.yaml already exists. Delete it manually before running this script.
```

## Manual Modification

You may always manually curate files based on the examples provided.
Loading

0 comments on commit a028983

Please sign in to comment.