agones.dev/agones@v1.54.0/build/includes/kind.mk (about)

     1  # Copyright 2019 Google LLC All Rights Reserved.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #     http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  
    15  
    16  #   _  ___           _
    17  #  | |/ (_)_ __   __| |
    18  #  | ' /| | '_ \ / _` |
    19  #  | . \| | | | | (_| |
    20  #  |_|\_\_|_| |_|\__,_|
    21  
    22  # creates a kind cluster for use with agones
    23  # Kind stand for Kubernetes IN Docker
    24  # You can change the cluster name using KIND_PROFILE env var
    25  kind-test-cluster: DOCKER_RUN_ARGS+=--network=host
    26  kind-test-cluster: $(ensure-build-image)
    27  	@if [ -z $$(kind get clusters | grep $(KIND_PROFILE)) ]; then\
    28  		echo "Could not find $(KIND_PROFILE) cluster. Creating...";\
    29  		kind create cluster --name $(KIND_PROFILE) --image kindest/node:v1.33.5 --wait 5m;\
    30  	fi
    31  
    32  # kind-metallb-helm-install installs metallb via helm for kind
    33  kind-metallb-helm-install:
    34  	helm repo add metallb https://metallb.github.io/metallb
    35  	helm repo update
    36  	helm upgrade metallb metallb/metallb --install --namespace metallb-system --create-namespace --version 0.15.2 --wait --timeout 180s
    37  
    38  # kind-metallb-configure configures metallb with an ip address range based on the kind node IP
    39  kind-metallb-configure:
    40  	KIND_IP=$$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $$(docker ps --filter "name=control-plane" --format "{{.Names}}" | head -n1)); \
    41  	NETWORK_PREFIX=$$(echo "$$KIND_IP" | cut -d '.' -f 1-3); \
    42  	METALLB_IP_RANGE="$$NETWORK_PREFIX.50-$$NETWORK_PREFIX.250"; \
    43  	sed "s|__RANGE__|$${METALLB_IP_RANGE}|g" $(build_path)/metallb-config.yaml.tpl | kubectl apply -f -
    44  
    45  # deletes the kind agones cluster
    46  # useful if you're want to start from scratch
    47  kind-delete-cluster:
    48  	kind delete cluster --name $(KIND_PROFILE)
    49  
    50  # start an interactive shell with kubectl configured to target the kind cluster
    51  kind-shell: $(ensure-build-image)
    52  	$(MAKE) shell DOCKER_RUN_ARGS="--network=host $(DOCKER_RUN_ARGS)"
    53  
    54  # installs the current dev version of agones
    55  # you should build-images and kind-push first.
    56  kind-install: PING_SERVICE_TYPE := LoadBalancer
    57  kind-install: ALLOCATOR_SERVICE_TYPE := LoadBalancer
    58  kind-install:
    59  	$(MAKE) install DOCKER_RUN_ARGS="--network=host" ALWAYS_PULL_SIDECAR=false \
    60  		IMAGE_PULL_POLICY=IfNotPresent PING_SERVICE_TYPE=$(PING_SERVICE_TYPE) \
    61  		ALLOCATOR_SERVICE_TYPE=$(ALLOCATOR_SERVICE_TYPE)
    62  
    63  # pushes the current dev version of agones to the kind single node cluster.
    64  kind-push:
    65  	docker tag $(sidecar_linux_amd64_tag) $(sidecar_tag)
    66  	docker tag $(controller_amd64_tag) $(controller_tag)
    67  	docker tag $(ping_amd64_tag) $(ping_tag)
    68  	docker tag $(allocator_amd64_tag) $(allocator_tag)
    69  	docker tag $(processor_amd64_tag) $(processor_tag)
    70  	docker tag $(extensions_amd64_tag) $(extensions_tag)
    71  
    72  	kind load docker-image $(sidecar_tag) --name="$(KIND_PROFILE)"
    73  	kind load docker-image $(controller_tag) --name="$(KIND_PROFILE)"
    74  	kind load docker-image $(ping_tag) --name="$(KIND_PROFILE)"
    75  	kind load docker-image $(allocator_tag) --name="$(KIND_PROFILE)"
    76  	kind load docker-image $(processor_tag) --name="$(KIND_PROFILE)"
    77  	kind load docker-image $(extensions_tag) --name="$(KIND_PROFILE)"
    78  
    79  # Runs e2e tests against our kind cluster
    80  kind-test-e2e:
    81  	$(MAKE) DOCKER_RUN_ARGS=--network=host test-e2e
    82  
    83  # prometheus on kind
    84  # we have to disable PVC as it's not supported on kind.
    85  kind-setup-prometheus:
    86  	$(MAKE) setup-prometheus DOCKER_RUN_ARGS="--network=host" PVC=false \
    87  		HELM_ARGS="--set server.resources.requests.cpu=0,server.resources.requests.memory=0"
    88  
    89  # grafana on kind with dashboards and prometheus datasource installed.
    90  # we have to disable PVC as it's not supported on kind.
    91  kind-setup-grafana:
    92  	$(MAKE) setup-grafana DOCKER_RUN_ARGS="--network=host" PVC=false
    93  
    94  kind-setup-prometheus-stack:
    95  	$(MAKE) setup-prometheus-stack DOCKER_RUN_ARGS="--network=host" PVC=false \
    96  		HELM_ARGS="--set prometheus.server.resources.requests.cpu=0,prometheus.server.resources.requests.memory=0"
    97  
    98  # kind port forwarding controller web
    99  kind-controller-portforward:
   100  	$(MAKE) controller-portforward DOCKER_RUN_ARGS="--network=host"
   101  
   102  # kind port forwarding grafana
   103  kind-grafana-portforward:
   104  	$(MAKE) grafana-portforward DOCKER_RUN_ARGS="--network=host"
   105  
   106  # kind port forwarding for prometheus web ui
   107  kind-prometheus-portforward:
   108  	$(MAKE) prometheus-portforward DOCKER_RUN_ARGS="--network=host"