Skip to content

Commit

Permalink
Use Kubernetes 1.25 in Quick Start docs and CAPD.
Browse files Browse the repository at this point in the history
Use kind 0.15.0 and Calico 3.24.1 in the Quick Start.
  • Loading branch information
oscr committed Sep 6, 2022
1 parent 723758b commit 31ef10c
Show file tree
Hide file tree
Showing 15 changed files with 306 additions and 51 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,10 @@ _releasenotes

# Helm
.helm

# Used during parts of the build process. Files _should_ get cleaned up automatically.
# This is also a good location for any temporary manfiests used during development
tmp

# asdf (not a typo! ;) used to manage multiple versions of tools
.tool-versions
122 changes: 122 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,128 @@ def prepare_all():
)
local(cmd, env = settings.get("kustomize_substitutions", {}))

# create cluster template resources from cluster-template files in the templates directory
def cluster_templates():
substitutions = settings.get("kustomize_substitutions", {})

# Ensure we have default values for a small set of well-known variables
substitutions["NAMESPACE"] = substitutions.get("NAMESPACE", "default")
substitutions["KUBERNETES_VERSION"] = substitutions.get("KUBERNETES_VERSION", "v1.25.0")
substitutions["CONTROL_PLANE_MACHINE_COUNT"] = substitutions.get("CONTROL_PLANE_MACHINE_COUNT", "1")
substitutions["WORKER_MACHINE_COUNT"] = substitutions.get("WORKER_MACHINE_COUNT", "3")

# Note: this is a workaround to pass env variables to cmd buttons while this is not supported natively like in local_resource
for name, value in substitutions.items():
os.environ[name] = value

template_dirs = settings.get("template_dirs", {
"docker": ["./test/infrastructure/docker/templates"],
})

for provider, provider_dirs in template_dirs.items():
p = providers.get(provider)
label = p.get("label", provider)

for template_dir in provider_dirs:
template_list = [filename for filename in listdir(template_dir) if os.path.basename(filename).endswith("yaml")]
for filename in template_list:
deploy_templates(filename, label, substitutions)

def deploy_templates(filename, label, substitutions):
# validate filename exists
if not os.path.exists(filename):
fail(filename + " not found")

basename = os.path.basename(filename)
if basename.endswith(".yaml"):
if basename.startswith("clusterclass-"):
template_name = basename.replace("clusterclass-", "").replace(".yaml", "")
deploy_clusterclass(template_name, label, filename, substitutions)
elif basename.startswith("cluster-template-"):
clusterclass_name = basename.replace("cluster-template-", "").replace(".yaml", "")
deploy_cluster_template(clusterclass_name, label, filename, substitutions)

def deploy_clusterclass(clusterclass_name, label, filename, substitutions):
apply_clusterclass_cmd = "cat " + filename + " | " + envsubst_cmd + " | " + kubectl_cmd + " apply --namespace=$NAMESPACE -f - && echo \"ClusterClass created from\'" + filename + "\', don't forget to delete\n\""
delete_clusterclass_cmd = kubectl_cmd + " --namespace=$NAMESPACE delete clusterclass " + clusterclass_name + ' --ignore-not-found=true; echo "\n"'

local_resource(
name = clusterclass_name,
cmd = ["bash", "-c", apply_clusterclass_cmd],
env = substitutions,
auto_init = False,
trigger_mode = TRIGGER_MODE_MANUAL,
labels = [label + ".clusterclasses"],
)

cmd_button(
clusterclass_name + ":apply",
argv = ["bash", "-c", apply_clusterclass_cmd],
resource = clusterclass_name,
icon_name = "note_add",
text = "Apply `" + clusterclass_name + "` ClusterClass",
inputs = [
text_input("NAMESPACE", default = substitutions.get("NAMESPACE")),
],
)

cmd_button(
clusterclass_name + ":delete",
argv = ["bash", "-c", delete_clusterclass_cmd],
resource = clusterclass_name,
icon_name = "delete_forever",
text = "Delete `" + clusterclass_name + "` ClusterClass",
inputs = [
text_input("NAMESPACE", default = substitutions.get("NAMESPACE")),
],
)

def deploy_cluster_template(template_name, label, filename, substitutions):
apply_cluster_template_cmd = "CLUSTER_NAME=" + template_name + "-$RANDOM;" + clusterctl_cmd + " generate cluster $CLUSTER_NAME --from " + filename + " | " + kubectl_cmd + " apply -f - && echo \"Cluster '$CLUSTER_NAME' created, don't forget to delete\n\""
delete_clusters_cmd = 'DELETED=$(echo "$(bash -c "' + kubectl_cmd + ' --namespace=$NAMESPACE get clusters -A --no-headers -o custom-columns=":metadata.name"")" | grep -E "^' + template_name + '-[[:digit:]]{1,5}$"); if [ -z "$DELETED" ]; then echo "Nothing to delete for cluster template ' + template_name + '"; else echo "Deleting clusters:\n$DELETED\n"; echo $DELETED | xargs -L1 ' + kubectl_cmd + ' delete cluster; fi; echo "\n"'

local_resource(
name = template_name,
cmd = ["bash", "-c", apply_cluster_template_cmd],
env = substitutions,
auto_init = False,
trigger_mode = TRIGGER_MODE_MANUAL,
labels = [label + ".templates"],
)

cmd_button(
template_name + ":apply",
argv = ["bash", "-c", apply_cluster_template_cmd],
resource = template_name,
icon_name = "add_box",
text = "Create `" + template_name + "` cluster",
inputs = [
text_input("NAMESPACE", default = substitutions.get("NAMESPACE")),
text_input("KUBERNETES_VERSION", default = substitutions.get("KUBERNETES_VERSION")),
text_input("CONTROL_PLANE_MACHINE_COUNT", default = substitutions.get("CONTROL_PLANE_MACHINE_COUNT")),
text_input("WORKER_MACHINE_COUNT", default = substitutions.get("WORKER_MACHINE_COUNT")),
],
)

cmd_button(
template_name + ":delete",
argv = ["bash", "-c", delete_clusters_cmd],
resource = template_name,
icon_name = "delete_forever",
text = "Delete `" + template_name + "` clusters",
inputs = [
text_input("NAMESPACE", default = substitutions.get("NAMESPACE")),
],
)

cmd_button(
template_name + ":delete-all",
argv = ["bash", "-c", kubectl_cmd + " delete clusters --all --wait=false"],
resource = template_name,
icon_name = "delete_sweep",
text = "Delete all workload clusters",
)

##############################
# Actual work happens here
##############################
Expand Down
37 changes: 37 additions & 0 deletions docs/book/src/developer/providers/v1.2-to-v1.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Cluster API v1.2 compared to v1.3

This document provides an overview over relevant changes between Cluster API v1.2 and v1.3 for
maintainers of providers and consumers of our Go API.

## Minimum Go version

* The Go version used by Cluster API is Go 1.19.x

## Dependencies

**Note**: Only the most relevant dependencies are listed, `k8s.io/` and `ginkgo`/`gomega` dependencies
in Cluster API are kept in sync with the versions used by `sigs.k8s.io/controller-runtime`.

- sigs.k8s.io/kind: v0.14.x => v0.15.x

## Changes by Kind

### Deprecation

- `sigs.k8s.io/cluster-api/controllers/external.CloneTemplate` has been deprecated and will be removed in a future release. Please use `sigs.k8s.io/cluster-api/controllers/external.CreateFromTemplate` instead.

### Removals

- `MachinesByCreationTimestamp` type has been removed.
- `ClusterCacheReconciler.Log` has been removed. Use the logger from the context instead.

### API Changes

-

### Other

- e2e tests are upgraded to use Ginkgo v2 (v2.1.4) and Gomega v1.20.0. Providers who use the test framework from this release will also need to upgrade, because Ginkgo v2 can't be imported alongside v1. Please see the [Ginkgo upgrade guide](https://onsi.github.io/ginkgo/MIGRATING_TO_V2), and note:
* the default test timeout has been [changed to 1h](https://onsi.github.io/ginkgo/MIGRATING_TO_V2#timeout-behavior)
* the `--junit-report` argument [replaces JUnit custom reporter](https://onsi.github.io/ginkgo/MIGRATING_TO_V2#improved-reporting-infrastructure) code
* see the ["Update tests to Ginkgo v2" PR](https://github.com/kubernetes-sigs/cluster-api/pull/6906) for a reference example
23 changes: 22 additions & 1 deletion docs/book/src/developer/tilt.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ workflow that offers easy deployments and rapid iterative builds.
## Prerequisites

1. [Docker](https://docs.docker.com/install/): v19.03 or newer
1. [kind](https://kind.sigs.k8s.io): v0.9 or newer
1. [kind](https://kind.sigs.k8s.io): v0.15 or newer
1. [Tilt](https://docs.tilt.dev/install.html): v0.22.2 or newer
1. [kustomize](https://github.com/kubernetes-sigs/kustomize): provided via `make kustomize`
1. [envsubst](https://github.com/drone/envsubst): provided via `make envsubst`
Expand Down Expand Up @@ -260,6 +260,27 @@ These can be customized for your specific needs.

<aside class="note">

### Deploying a workload cluster

After your kind management cluster is up and running with Tilt, you can deploy a workload clusters in the Tilt web UI based off of YAML templates from the directories specified in
the `template_dirs` field from the [tilt-settings.yaml](#tilt-settings-fields) file (default `./test/infrastructure/docker/templates`).

Templates should be named according to clusterctl conventions:

- template files must be named `cluster-template-{name}.yaml`; those files will be accessible in the Tilt web UI under the label grouping `{provider-label}.templates`, i.e. `CAPD.templates`.
- cluster class files must be named `clusterclass-{name}.yaml`; those file will be accessible in the Tilt web UI under the label grouping `{provider-label}.clusterclasses`, i.e. `CAPD.clusterclasses`.

By selecting one of those items in the Tilt web UI set of buttons will appear, allowing to create - with a dropdown for customizing variable substitutions - or delete clusters.
Custom values for variable substitutions can be set using `kustomize_substitutions` in `tilt-settings.yaml`, e.g.

```yaml
kustomize_substitutions:
NAMESPACE: default
KUBERNETES_VERSION: v1.25.0
CONTROL_PLANE_MACHINE_COUNT: 1
WORKER_MACHINE_COUNT: 3
```

<h1>Use of clusterctl</h1>

When the worker cluster has been created using tilt, `clusterctl` should not be used for management
Expand Down
23 changes: 16 additions & 7 deletions docs/book/src/user/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ a target [management cluster] on the selected [infrastructure provider].

[kind] is not designed for production use.

**Minimum [kind] supported version**: v0.14.0
**Minimum [kind] supported version**: v0.15.0

**Help with common issues can be found in the [Troubleshooting Guide](./troubleshooting.md).**

Expand Down Expand Up @@ -948,7 +948,7 @@ The Docker provider is not designed for production use and is intended for devel
```bash
clusterctl generate cluster capi-quickstart --flavor development \
--kubernetes-version v1.24.0 \
--kubernetes-version v1.25.0 \
--control-plane-machine-count=3 \
--worker-machine-count=3 \
> capi-quickstart.yaml
Expand All @@ -960,7 +960,7 @@ clusterctl generate cluster capi-quickstart --flavor development \
```bash
export CLUSTER_NAME=kind
export CLUSTER_NAMESPACE=vcluster
export KUBERNETES_VERSION=1.23.4
export KUBERNETES_VERSION=1.25.0
export HELM_VALUES="service:\n type: NodePort"
kubectl create namespace ${CLUSTER_NAMESPACE}
Expand All @@ -975,7 +975,7 @@ clusterctl generate cluster ${CLUSTER_NAME} \
```bash
clusterctl generate cluster capi-quickstart \
--kubernetes-version v1.24.0 \
--kubernetes-version v1.25.0 \
--control-plane-machine-count=3 \
--worker-machine-count=3 \
> capi-quickstart.yaml
Expand Down Expand Up @@ -1034,8 +1034,8 @@ kubectl get kubeadmcontrolplane
You should see an output is similar to this:
```bash
NAME INITIALIZED API SERVER AVAILABLE VERSION REPLICAS READY UPDATED UNAVAILABLE
capi-quickstart-control-plane true v1.24.0 3 3 3
NAME CLUSTER INITIALIZED API SERVER AVAILABLE REPLICAS READY UPDATED UNAVAILABLE AGE VERSION
capi-quickstart-g2trk capi-quickstart true 3 3 3 4m7s v1.25.0
```
<aside class="note warning">
Expand Down Expand Up @@ -1091,7 +1091,7 @@ Calico not required for vcluster.
```bash
kubectl --kubeconfig=./capi-quickstart.kubeconfig \
apply -f https://docs.projectcalico.org/v3.21/manifests/calico.yaml
apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.24.1/manifests/calico.yaml
```
After a short while, our nodes should be running and in `Ready` state,
Expand All @@ -1100,6 +1100,15 @@ let's check the status using `kubectl get nodes`:
```bash
kubectl --kubeconfig=./capi-quickstart.kubeconfig get nodes
```
```bash
NAME STATUS ROLES AGE VERSION
capi-quickstart-g2trk-9xrjv Ready control-plane 12m v1.25.0
capi-quickstart-g2trk-bmm9v Ready control-plane 11m v1.25.0
capi-quickstart-g2trk-hvs9q Ready control-plane 13m v1.25.0
capi-quickstart-md-0-55x6t-5649968bd7-8tq9v Ready <none> 12m v1.25.0
capi-quickstart-md-0-55x6t-5649968bd7-glnjd Ready <none> 12m v1.25.0
capi-quickstart-md-0-55x6t-5649968bd7-sfzp6 Ready <none> 12m v1.25.0
```
{{#/tab }}
{{#/tabs }}
Expand Down
2 changes: 1 addition & 1 deletion hack/ensure-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set -o pipefail
set -x

GOPATH_BIN="$(go env GOPATH)/bin/"
MINIMUM_KIND_VERSION=v0.14.0
MINIMUM_KIND_VERSION=v0.15.0
goarch="$(go env GOARCH)"
goos="$(go env GOOS)"

Expand Down
14 changes: 7 additions & 7 deletions test/e2e/config/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ variables:
# allowing the same e2e config file to be re-used in different Prow jobs e.g. each one with a K8s version permutation.
# The following Kubernetes versions should be the latest versions with already published kindest/node images.
# This avoids building node images in the default case which improves the test duration significantly.
KUBERNETES_VERSION_MANAGEMENT: "v1.24.0"
KUBERNETES_VERSION: "v1.24.0"
KUBERNETES_VERSION_UPGRADE_FROM: "v1.23.6"
KUBERNETES_VERSION_UPGRADE_TO: "v1.24.0"
ETCD_VERSION_UPGRADE_TO: "3.5.3-0"
COREDNS_VERSION_UPGRADE_TO: "v1.8.6"
KUBERNETES_VERSION_MANAGEMENT: "v1.25.0"
KUBERNETES_VERSION: "v1.25.0"
KUBERNETES_VERSION_UPGRADE_FROM: "1.24.4"
KUBERNETES_VERSION_UPGRADE_TO: "v1.25.0"
ETCD_VERSION_UPGRADE_TO: "3.5.4-0"
COREDNS_VERSION_UPGRADE_TO: "v1.9.3"
DOCKER_SERVICE_DOMAIN: "cluster.local"
IP_FAMILY: "IPv4"
DOCKER_SERVICE_CIDRS: "10.128.0.0/12"
Expand All @@ -233,7 +233,7 @@ variables:
# NOTE: We test the latest release with a previous contract.
INIT_WITH_BINARY: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.7/clusterctl-{OS}-{ARCH}"
INIT_WITH_PROVIDERS_CONTRACT: "v1alpha4"
INIT_WITH_KUBERNETES_VERSION: "v1.24.0"
INIT_WITH_KUBERNETES_VERSION: "v1.25.0"

intervals:
default/wait-controllers: ["3m", "10s"]
Expand Down
2 changes: 1 addition & 1 deletion test/framework/bootstrap/kind_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
DefaultNodeImageRepository = "kindest/node"

// DefaultNodeImageVersion is the default Kubernetes version to be used for creating a kind cluster.
DefaultNodeImageVersion = "v1.24.0"
DefaultNodeImageVersion = "v1.25.0"
)

// KindClusterOption is a NewKindClusterProvider option.
Expand Down
Loading

0 comments on commit 31ef10c

Please sign in to comment.