Skip to content

Commit

Permalink
Merge pull request #7365 from fabriziopandini/simplify-make-targets
Browse files Browse the repository at this point in the history
🌱 Simplify Makefile targets
  • Loading branch information
k8s-ci-robot authored Oct 11, 2022
2 parents 36bedd6 + 1564438 commit efb7e86
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 230 deletions.
134 changes: 55 additions & 79 deletions Makefile

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions cloudbuild-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ steps:
- DOCKER_BUILDKIT=1
args:
- release-staging-nightly
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20221007-ad65926f6b'
entrypoint: make
env:
- DOCKER_CLI_EXPERIMENTAL=enabled
- TAG=$_GIT_TAG
- PULL_BASE_REF=$_PULL_BASE_REF
- DOCKER_BUILDKIT=1
args:
- release-capd-staging-nightly
substitutions:
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
# can be used as a substitution
Expand Down
9 changes: 0 additions & 9 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ steps:
- DOCKER_BUILDKIT=1
args:
- release-staging
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20221007-ad65926f6b'
entrypoint: make
env:
- DOCKER_CLI_EXPERIMENTAL=enabled
- TAG=$_GIT_TAG
- PULL_BASE_REF=$_PULL_BASE_REF
- DOCKER_BUILDKIT=1
args:
- release-capd-staging
substitutions:
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
# can be used as a substitution
Expand Down
8 changes: 1 addition & 7 deletions docs/book/src/clusterctl/developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,12 @@ If you want to create a local artifact, follow these instructions:

### Build artifacts locally

In order to build artifacts for the CAPI core provider, the kubeadm bootstrap provider and the kubeadm control plane provider:
In order to build artifacts for the CAPI core provider, the kubeadm bootstrap provider, the kubeadm control plane provider and the docker infrastructure provider:

```bash
make docker-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent
```

In order to build docker provider artifacts

```bash
make docker-capd-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent
```

### Create a clusterctl-settings.json file

Next, create a `clusterctl-settings.json` file and place it in your local copy
Expand Down
105 changes: 5 additions & 100 deletions docs/book/src/developer/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,114 +107,19 @@ Many of the Cluster API engineers use it for quick iteration. Please see our [Ti

## Option 2: The Old-fashioned way

### Building everything

You'll need to build two docker images, one for Cluster API itself and one for the Docker provider (CAPD).

```bash
# Build all the images
make docker-build
make docker-capd-build
```

### Push both images

```bash
# Push images
make docker-push
```
```bash
docker push gcr.io/cluster-api-242700/cluster-api-controller-amd64:dev
The push refers to repository [gcr.io/cluster-api-242700/cluster-api-controller-amd64]
90a39583ad5f: Layer already exists
932da5156413: Layer already exists
dev: digest: sha256:263262cfbabd3d1add68172a5a1d141f6481a2bc443672ce80778dc122ee6234 size: 739
```
```bash
$ make docker-capd-push
```
```bash
docker push gcr.io/cluster-api-242700/capd-manager-amd64:dev
The push refers to repository [gcr.io/cluster-api-242700/capd-manager-amd64]
```

Make a note of the URLs and the digests. You'll need them for the next step. In this case, they're...

`gcr.io/cluster-api-242700/capd-manager-amd64@sha256:35670a049372ae063dad910c267a4450758a139c4deb248c04c3198865589ab2`

and

`gcr.io/cluster-api-242700/cluster-api-controller-amd64@sha256:263262cfbabd3d1add68172a5a1d141f6481a2bc443672ce80778dc122ee6234`

### Edit the manifests

```bash
$EDITOR config/default/manager_image_patch.yaml
$EDITOR test/infrastructure/docker/config/default/manager_image_patch.yaml
```

In both cases, change the `- image:` url to the digest URL mentioned above:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller-manager
namespace: system
spec:
template:
spec:
containers:
- image: gcr.io/cluster-api-242700/capd-manager-amd64@sha256:35670a049372ae063dad910c267a4450758a139c4deb248c04c3198865589ab2`
name: manager
```
### Apply the manifests
```bash
# Apply the manifests
kustomize build config/default | ./hack/tools/bin/envsubst | kubectl apply -f -
```
```bash
namespace/capi-system configured
customresourcedefinition.apiextensions.k8s.io/clusters.cluster.x-k8s.io configured
customresourcedefinition.apiextensions.k8s.io/kubeadmconfigs.bootstrap.cluster.x-k8s.io configured
customresourcedefinition.apiextensions.k8s.io/kubeadmconfigtemplates.bootstrap.cluster.x-k8s.io configured
customresourcedefinition.apiextensions.k8s.io/machinedeployments.cluster.x-k8s.io configured
customresourcedefinition.apiextensions.k8s.io/machines.cluster.x-k8s.io configured
customresourcedefinition.apiextensions.k8s.io/machinesets.cluster.x-k8s.io configured
role.rbac.authorization.k8s.io/capi-leader-election-role configured
clusterrole.rbac.authorization.k8s.io/capi-manager-role configured
rolebinding.rbac.authorization.k8s.io/capi-leader-election-rolebinding configured
clusterrolebinding.rbac.authorization.k8s.io/capi-manager-rolebinding configured
deployment.apps/capi-controller-manager created
```
```bash
kustomize build bootstrap/kubeadm/config | ./hack/tools/bin/envsubst | kubectl apply -f -
kustomize build controlplane/kubeadm/config | ./hack/tools/bin/envsubst | kubectl apply -f -
kustomize build test/infrastructure/docker/config/default | ./hack/tools/bin/envsubst | kubectl apply -f -
```
```bash
namespace/capd-system configured
customresourcedefinition.apiextensions.k8s.io/dockerclusters.infrastructure.cluster.x-k8s.io configured
customresourcedefinition.apiextensions.k8s.io/dockermachines.infrastructure.cluster.x-k8s.io configured
customresourcedefinition.apiextensions.k8s.io/dockermachinetemplates.infrastructure.cluster.x-k8s.io configured
role.rbac.authorization.k8s.io/capd-leader-election-role configured
clusterrole.rbac.authorization.k8s.io/capd-manager-role configured
clusterrole.rbac.authorization.k8s.io/capd-proxy-role configured
rolebinding.rbac.authorization.k8s.io/capd-leader-election-rolebinding configured
clusterrolebinding.rbac.authorization.k8s.io/capd-manager-rolebinding configured
clusterrolebinding.rbac.authorization.k8s.io/capd-proxy-rolebinding configured
service/capd-controller-manager-metrics-service created
deployment.apps/capd-controller-manager created
```

### Check the status of the clusters

```bash
kubectl get po -n capd-system
```
```bash
NAME READY STATUS RESTARTS AGE
capd-controller-manager-7568c55d65-ndpts 2/2 Running 0 71s
kubectl get po -n capi-system
NAME READY STATUS RESTARTS AGE
capi-controller-manager-bf9c6468c-d6msj 1/1 Running 0 2m9s
```

## Testing

Expand Down
4 changes: 2 additions & 2 deletions docs/book/src/reference/jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ GitHub Presubmit Workflows:
### Postsubmits

Prow Postsubmits:
* [post-cluster-api-push-images] Google Cloud Build: `make release-staging`, `make release-capd-staging`
* [post-cluster-api-push-images] Google Cloud Build: `make release-staging`

### Periodics

Expand Down Expand Up @@ -75,7 +75,7 @@ Prow Periodics:
* GINKGO_FOCUS: `[K8s-Upgrade]`
* [periodic-cluster-api-e2e-workload-upgrade-1-25-latest-main] `./scripts/ci-e2e.sh` FROM: `stable-1.25` TO: `ci/latest-1.26`
* GINKGO_FOCUS: `[K8s-Upgrade]`
* [cluster-api-push-images-nightly] Google Cloud Build: `make release-staging-nightly`, `make release-capd-staging-nightly`
* [cluster-api-push-images-nightly] Google Cloud Build: `make release-staging-nightly`

## Test-infra configuration

Expand Down
29 changes: 7 additions & 22 deletions scripts/ci-e2e-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# capi:buildDockerImages builds all the CAPI (and CAPD) docker images, if not already present locally.
# capi:buildDockerImages builds all the required docker images, if not already present locally.
capi:buildDockerImages () {
# Configure provider images generation;
# please ensure the generated image name matches image names used in the E2E_CONF_FILE
# please ensure the generated image name matches image names used in the E2E_CONF_FILE;
# also the same settings must be set in Makefile, docker-build-e2e target.
ARCH="$(go env GOARCH)"
export REGISTRY=gcr.io/k8s-staging-cluster-api
export TAG=dev
export ARCH
export PULL_POLICY=IfNotPresent

## Build all Cluster API provider images, if missing
## Build all required docker image, if missing.
## Note: we check only for one image to exist, and assume that if one is missing all are missing.
if [[ "$(docker images -q "$REGISTRY/cluster-api-controller-$ARCH:$TAG" 2> /dev/null)" == "" ]]; then
echo "+ Building CAPI images"
make docker-build
echo "+ Building CAPI images and CAPD image"
make docker-build-e2e
else
echo "+ CAPI images already present in the system, skipping make"
fi

## Build CAPD provider images, if missing
if [[ "$(docker images -q "$REGISTRY/capd-manager-$ARCH:$TAG" 2> /dev/null)" == "" ]]; then
echo "+ Building CAPD images"
make docker-capd-build
else
echo "+ CAPD images already present in the system, skipping make"
fi

## Build test extension images, if missing
if [[ "$(docker images -q "$REGISTRY/test-extension-$ARCH:$TAG" 2> /dev/null)" == "" ]]; then
echo "+ Building test-extension image"
make docker-build-test-extension
else
echo "+ test-extension image already present in the system, skipping make"
fi
}

# k8s::prepareKindestImages checks all the e2e test variables representing a Kubernetes version,
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ make test-junit

echo -e "\n*** Testing Cluster API Provider Docker ***\n"
# Docker provider
make test-capd-junit
make test-docker-infrastructure-junit

echo -e "\n*** Testing Cluster API Runtime SDK test extension ***\n"
# Test Extension
Expand Down
2 changes: 1 addition & 1 deletion test/infrastructure/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ For a complete overview, please refer to the documentation available [here](http
## Testing

In order to test your local changes, go to the top level directory of this project, `cluster-api/` and run
`make test-capd` to run the unit tests.
`make test-docker-infrastructure` to run the unit tests.

**Note:** `make test-e2e` runs the CAPI E2E tests that are based on CAPD (CAPD does not have a separated e2e suite).

Expand Down

0 comments on commit efb7e86

Please sign in to comment.