-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from adrianchiris/create-minikube-dev-env
Create minikube dev env
- Loading branch information
Showing
8 changed files
with
223 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,6 @@ go.work.sum | |
# build dirs | ||
build/ | ||
bin/ | ||
|
||
# IDE | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Adds namespace to all resources. | ||
namespace: maintenance-operator-system | ||
namePrefix: maintenance-operator- | ||
|
||
resources: | ||
- ../crd | ||
- ../rbac | ||
- ../manager | ||
|
||
patches: | ||
- path: manager_debug_patch.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
spec: | ||
template: | ||
spec: | ||
securityContext: null | ||
containers: | ||
- name: manager | ||
securityContext: null | ||
livenessProbe: null | ||
readinessProbe: null | ||
resources: null | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/bin/bash | ||
|
||
# 2024 NVIDIA CORPORATION & AFFILIATES | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the License); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an AS IS BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -o nounset | ||
set -o pipefail | ||
set -o errexit | ||
|
||
if [[ "${TRACE-0}" == "1" ]]; then | ||
set -o xtrace | ||
fi | ||
|
||
CLUSTER_NAME="${CLUSTER_NAME:-"mn-op"}" | ||
MINIKUBE_BIN="${MINIKUBE_BIN:-"unknown"}" | ||
# Docker is used as the minikube driver to enable using hollow nodes. | ||
MINIKUBE_DRIVER="${MINIKUBE_DRIVER:-"unknown"}" | ||
USE_MINIKUBE_DOCKER="${USE_MINIKUBE_DOCKER:-"true"}" | ||
NUM_NODES="${NUM_NODES:-"1"}" | ||
NODE_MEMORY="${NODE_MEMORY:-"8g"}" | ||
NODE_CPUS="${NODE_CPUS:-"4"}" | ||
NODE_DISK="${NODE_DISK:-"100g"}" | ||
MINIKUBE_CNI="${MINIKUBE_CNI:-kindnet}" | ||
MINIKUBE_KUBERNETES_VERSION="${MINIKUBE_KUBERNETES_VERSION:-"v1.30.0"}" | ||
|
||
## Detect the OS. | ||
OS="unknown" | ||
if [[ "${OSTYPE}" == "linux"* ]]; then | ||
OS="linux" | ||
elif [[ "${OSTYPE}" == "darwin"* ]]; then | ||
OS="darwin" | ||
fi | ||
|
||
# Exit if the OS is not supported. | ||
if [[ "$OS" == "unknown" ]]; then | ||
echo "os '$OSTYPE' not supported. Aborting." >&2 | ||
exit 1 | ||
fi | ||
|
||
## Set the driver used for minikube machines. By default this script will select the preferred VM driver for each OS. | ||
## Users can override this using the MINIKUBE_DRIVER env variable. | ||
if [[ "$MINIKUBE_DRIVER" == "unknown" ]]; then | ||
if [[ "${OSTYPE}" == "linux"* ]]; then | ||
MINIKUBE_DRIVER="kvm2" | ||
elif [[ "${OSTYPE}" == "darwin"* ]]; then | ||
MINIKUBE_DRIVER="qemu" | ||
fi | ||
fi | ||
|
||
MINIKUBE_ARGS="${MINIKUBE_ARGS:-"\ | ||
--driver $MINIKUBE_DRIVER \ | ||
--cpus=$NODE_CPUS \ | ||
--memory=$NODE_MEMORY \ | ||
--disk-size=$NODE_DISK \ | ||
--nodes=$NUM_NODES \ | ||
--cni $MINIKUBE_CNI \ | ||
--kubernetes-version $MINIKUBE_KUBERNETES_VERSION \ | ||
--preload=true \ | ||
--cache-images=true \ | ||
--addons registry"}" | ||
|
||
MINIKUBE_EXTRA_ARGS="${MINIKUBE_EXTRA_ARGS:-""}" | ||
|
||
echo "Setting up Minikube cluster..." | ||
|
||
## Exit early if the cluster already exists. | ||
if [[ $($MINIKUBE_BIN status -p $CLUSTER_NAME -f '{{.Name}}') == $CLUSTER_NAME ]]; then | ||
echo "Minikube cluster '$CLUSTER_NAME' found. Skipping cluster set-up" | ||
## Set environment variables to use the Minikube VM docker build for | ||
if [[ "$USE_MINIKUBE_DOCKER" == "true" ]]; then | ||
echo "Setting environment variables to use $CLUSTER_NAME as docker build environment." | ||
eval $($MINIKUBE_BIN -p $CLUSTER_NAME docker-env) | ||
fi | ||
exit 0 | ||
fi | ||
|
||
$MINIKUBE_BIN start --profile $CLUSTER_NAME $MINIKUBE_ARGS $MINIKUBE_EXTRA_ARGS | ||
|
||
## Set environment variables to use the Minikube VM docker build for | ||
if [[ "$USE_MINIKUBE_DOCKER" == "true" ]]; then | ||
echo "Setting environment variables to use $CLUSTER_NAME as docker build environment." | ||
eval $($MINIKUBE_BIN -p $CLUSTER_NAME docker-env) | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apiVersion: skaffold/v4beta11 | ||
kind: Config | ||
metadata: | ||
name: maintenance-operator | ||
|
||
profiles: | ||
- name: operator | ||
build: | ||
local: | ||
useBuildkit: true | ||
artifacts: | ||
- image: nvidia.com/maintenance-operator | ||
runtimeType: go | ||
docker: | ||
dockerfile: Dockerfile | ||
buildArgs: | ||
# Used for debugging. Disable inlining and optimizations in the go compiler. Passed to go build using `-gcflags` | ||
GCFLAGS: "all=-N -l" | ||
manifests: | ||
## Deploy the manager. | ||
kustomize: | ||
paths: | ||
- config/debug | ||
|
||
portForward: | ||
- resourceType: deployment | ||
resourceName: maintenance-operator-controller-manager | ||
namespace: maintenance-operator-system | ||
port: 56268 | ||
localPort: 8082 | ||
address: 0.0.0.0 |