зеркало из https://github.com/Azure/ARO-RP.git
Refactor Hive Directory (#3765)
* Move Hive hack files under one directory Group the Hive files under hack directory to hack/hive * Refactor Hive installation and hack files location Group the Hive files under hack directory to hack/hive, and refactor Hive installation using main function and utils.sh * Print troubleshooting for Hive deployment rollout Trust in the operator installation and print two options to monitor Hive deployment rollout * Small fixes for hive installation script Use double quote to prevent word splitting, break long line into multiple, use '-n' over '! -z', simpler if check, use consistent function declaration syntax, trap outside main and after cleanup is declared
This commit is contained in:
Родитель
fa7af61f57
Коммит
abf4167f01
|
@ -33,8 +33,8 @@ gomock_reflect_*
|
|||
/portal/v2/node_modules/
|
||||
portal/v2/.vscode/
|
||||
.idea*
|
||||
/hack/hive-config/crds
|
||||
/hack/hive-config/hive-deployment.yaml
|
||||
/hack/hive/hive-config/crds
|
||||
/hack/hive/hive-config/hive-deployment.yaml
|
||||
cmd/aro/__debug_bin
|
||||
megalinter-reports/
|
||||
/db
|
||||
|
|
|
@ -105,8 +105,8 @@
|
|||
1. Now that your machine is able access the AKS cluster, you can deploy Hive:
|
||||
```bash
|
||||
make aks.kubeconfig
|
||||
./hack/hive-generate-config.sh
|
||||
KUBECONFIG=$(pwd)/aks.kubeconfig ./hack/hive-dev-install.sh
|
||||
./hack/hive/hive-generate-config.sh
|
||||
KUBECONFIG=$(pwd)/aks.kubeconfig ./hack/hive/hive-dev-install.sh
|
||||
```
|
||||
|
||||
1. Mirror the OpenShift images to your new Azure Container Registry (ACR)
|
||||
|
|
13
docs/hive.md
13
docs/hive.md
|
@ -2,13 +2,13 @@
|
|||
|
||||
## Version
|
||||
|
||||
The commit sha is used to specify the image tag and also used during config generation to checkout the correct version of the config files. The config files are subsequently used by the `hack/hive-dev-install.sh` script during installation or during config updates.
|
||||
The commit sha is used to specify the image tag and also used during config generation to checkout the correct version of the config files. The config files are subsequently used by the `hack/hive/hive-dev-install.sh` script during installation or during config updates.
|
||||
|
||||
1. You can either
|
||||
1. Provide the hive image commit has as an argument to `hack/hive-generate-config.sh`. This is useful for testing new hive images before hive releases.
|
||||
1. Example: `./hack/hive-generate-config.sh d7ead609f4`
|
||||
1. Provide the hive image commit has as an argument to `hack/hive/hive-generate-config.sh`. This is useful for testing new hive images before hive releases.
|
||||
1. Example: `./hack/hive/hive-generate-config.sh d7ead609f4`
|
||||
2. Accept the default version by providing no arguments, which should be the latest.
|
||||
1. Example: `./hack/hive-generate-config.sh`
|
||||
1. Example: `./hack/hive/hive-generate-config.sh`
|
||||
|
||||
## Generating config
|
||||
|
||||
|
@ -18,7 +18,7 @@ In order to generate config for a dev environment you need to ensure you have th
|
|||
# source your environment file
|
||||
. ./env
|
||||
# run the config generation
|
||||
./hack/hive-generate-config.sh
|
||||
./hack/hive/hive-generate-config.sh
|
||||
```
|
||||
|
||||
This will download the latest source, reset to the hash specified in HIVE_IMAGE_COMMIT_HASH, and build the config using kustomise.
|
||||
|
@ -41,5 +41,6 @@ This will download the latest source, reset to the hash specified in HIVE_IMAGE_
|
|||
```
|
||||
4. Installing then simply requires the running of the install script.
|
||||
```bash
|
||||
./hack/hive-dev-install.sh
|
||||
./hack/hive/hive-dev-install.sh
|
||||
```
|
||||
> __NOTE:__ When Hive is already installed and SKIP_DEPLOYMENTS is set to "true" then Hive installation can be skipped without user's approval.
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
HIVE_OPERATOR_NS="hive"
|
||||
KUBECTL=$( which kubectl 2> /dev/null || which oc 2> /dev/null)
|
||||
|
||||
function cleanup {
|
||||
[ -f "$(pwd)/kubectl" ] && rm -f "$(pwd)/kubectl"
|
||||
}
|
||||
|
||||
function download_tmp_kubectl {
|
||||
curl -sLO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ": error downloading kubectl"
|
||||
exit 1
|
||||
fi
|
||||
chmod 755 kubectl
|
||||
KUBECTL="$(pwd)/kubectl"
|
||||
}
|
||||
|
||||
function verify_tools {
|
||||
if [ ! -z "$KUBECTL" ]; then
|
||||
return
|
||||
fi
|
||||
echo -n "kubectl or oc not detected, downloading"
|
||||
download_tmp_kubectl
|
||||
echo ", done."
|
||||
|
||||
if [ $( $KUBECTL get nodes 2>/dev/null | wc -l ) -eq 0 ]; then
|
||||
echo "unable to connect to the cluster"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
set -e
|
||||
trap cleanup EXIT
|
||||
|
||||
if [ ! -f go.mod ] || [ ! -d ".git" ]; then
|
||||
echo "this script must by run from the repo's root directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "./hack/hive-config/hive-deployment.yaml" ] || [ ! -d "./hack/hive-config/crds" ] ; then
|
||||
echo "hive config is missing, generating config, please rerun this script afterwards"
|
||||
./hack/hive-generate-config.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "error generating the hive configs"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$PULL_SECRET" ]; then
|
||||
echo "global pull secret variable required, please source ./env"
|
||||
exit
|
||||
fi
|
||||
|
||||
verify_tools
|
||||
|
||||
if [ $( $KUBECTL get namespace $HIVE_OPERATOR_NS -o yaml 2>/dev/null | wc -l ) -ne 0 ]; then
|
||||
echo "hive is already installed in the namespace"
|
||||
echo -n "would you like to reapply the configs? (y/N): "
|
||||
read answer
|
||||
if [[ "$answer" != "y" ]]; then
|
||||
exit
|
||||
fi
|
||||
else
|
||||
$KUBECTL create namespace $HIVE_OPERATOR_NS
|
||||
fi
|
||||
|
||||
$KUBECTL apply -f ./hack/hive-config/crds
|
||||
|
||||
echo "$PULL_SECRET" > /tmp/.tmp-secret
|
||||
# Using dry-run allows updates to work seamlessly
|
||||
$KUBECTL create secret generic hive-global-pull-secret --from-file=.dockerconfigjson=/tmp/.tmp-secret --type=kubernetes.io/dockerconfigjson --namespace $HIVE_OPERATOR_NS -o yaml --dry-run=client | $KUBECTL apply -f - 2>/dev/null
|
||||
rm -f /tmp/.tmp-secret
|
||||
|
||||
sed "s/HIVE_OPERATOR_NS/$HIVE_OPERATOR_NS/g" hack/hive-config/hive-config.yaml | $KUBECTL apply -f -
|
||||
$KUBECTL apply -f ./hack/hive-config/hive-additional-install-log-regexes.yaml
|
||||
|
||||
$KUBECTL apply -f ./hack/hive-config/hive-deployment.yaml
|
||||
|
||||
$KUBECTL wait --timeout=5m --for=condition=Available --namespace $HIVE_OPERATOR_NS deployment/hive-operator
|
||||
$KUBECTL wait --timeout=5m --for=condition=Available --namespace $HIVE_OPERATOR_NS deployment/hive-controllers
|
||||
$KUBECTL wait --timeout=5m --for=condition=Ready --namespace $HIVE_OPERATOR_NS pod --selector "control-plane=clustersync"
|
||||
|
||||
echo -e "\nHive is installed."
|
|
@ -3,4 +3,4 @@ package hiveconfig
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the Apache License 2.0.
|
||||
|
||||
//go:generate go run ../genhiveconfig ./hive-additional-install-log-regexes.yaml
|
||||
//go:generate go run ../../genhiveconfig ./hive-additional-install-log-regexes.yaml
|
|
@ -0,0 +1,98 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -o errexit \
|
||||
-o nounset
|
||||
|
||||
declare -r utils=hack/util.sh
|
||||
if [ -f "$utils" ]; then
|
||||
# shellcheck source=../util.sh
|
||||
source "$utils"
|
||||
fi
|
||||
|
||||
HIVE_OPERATOR_NS="hive"
|
||||
KUBECTL="$( which kubectl 2> /dev/null || which oc 2> /dev/null)"
|
||||
|
||||
if [ ! -f go.mod ] || [ ! -d ".git" ]; then
|
||||
abort "this script must by run from the repo's root directory"
|
||||
fi
|
||||
|
||||
|
||||
function cleanup() {
|
||||
[ -f "$(pwd)/kubectl" ] && rm -f "$(pwd)/kubectl"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
main() {
|
||||
log "enter hive installation"
|
||||
local skip_deployments=${1:-"none"}
|
||||
|
||||
if [ ! -f "./hack/hive/hive-config/hive-deployment.yaml" ] || [ ! -d "./hack/hive/hive-config/crds" ] ; then
|
||||
log "hive config is missing, generating config, please rerun this script afterwards"
|
||||
./hack/hive/hive-generate-config.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
abort "error generating the hive configs"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$PULL_SECRET" ]; then
|
||||
log "global pull secret variable required, please source ./env"
|
||||
exit
|
||||
fi
|
||||
verify_tools
|
||||
|
||||
if [ "$( $KUBECTL get namespace $HIVE_OPERATOR_NS -o yaml 2>/dev/null | wc -l )" -ne 0 ]; then
|
||||
log "hive is already installed in namespace $HIVE_OPERATOR_NS"
|
||||
log -n "would you like to reapply the configs? (y/N): "
|
||||
read answer
|
||||
if [[ "$answer" != "y" ]]; then
|
||||
exit
|
||||
fi
|
||||
else
|
||||
$KUBECTL create namespace $HIVE_OPERATOR_NS
|
||||
fi
|
||||
|
||||
log "Hive is ready to be installed"
|
||||
$KUBECTL apply -f ./hack/hive/hive-config/crds
|
||||
echo "$PULL_SECRET" > /tmp/.tmp-secret
|
||||
# Using dry-run allows updates to work seamlessly
|
||||
$KUBECTL create secret generic hive-global-pull-secret \
|
||||
--from-file=.dockerconfigjson=/tmp/.tmp-secret \
|
||||
--type=kubernetes.io/dockerconfigjson \
|
||||
--namespace $HIVE_OPERATOR_NS \
|
||||
-o yaml \
|
||||
--dry-run=client \
|
||||
| $KUBECTL apply -f - 2>/dev/null
|
||||
rm -f /tmp/.tmp-secret
|
||||
|
||||
sed "s/HIVE_OPERATOR_NS/$HIVE_OPERATOR_NS/g" hack/hive/hive-config/hive-config.yaml | $KUBECTL apply -f -
|
||||
$KUBECTL apply -f ./hack/hive/hive-config/hive-additional-install-log-regexes.yaml
|
||||
$KUBECTL apply -f ./hack/hive/hive-config/hive-deployment.yaml
|
||||
$KUBECTL wait --timeout=5m --for=condition=Available --namespace $HIVE_OPERATOR_NS deployment/hive-operator
|
||||
|
||||
log "Hive is installed but to check Hive readiness use one of the following options to monitor the deployment rollout:
|
||||
'kubectl wait --timeout=5m --for=condition=Available --namespace "$HIVE_OPERATOR_NS" deployment/hive-controllers'
|
||||
or 'kubectl wait --timeout=5m --for=condition=Ready --namespace "$HIVE_OPERATOR_NS" pod --selector control-plane=clustersync'"
|
||||
}
|
||||
|
||||
function download_tmp_kubectl() {
|
||||
if curl -sLO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"; then
|
||||
abort ": error downloading kubectl"
|
||||
fi
|
||||
chmod 755 kubectl
|
||||
KUBECTL="$(pwd)/kubectl"
|
||||
}
|
||||
|
||||
function verify_tools() {
|
||||
if [ -n "$KUBECTL" ]; then
|
||||
return
|
||||
fi
|
||||
log "kubectl or oc not detected, downloading"
|
||||
download_tmp_kubectl
|
||||
log "done: downloading kubectl/oc was completed"
|
||||
|
||||
if [ "$( $KUBECTL get nodes 2>/dev/null | wc -l )" -eq 0 ]; then
|
||||
abort "unable to connect to the cluster"
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
|
@ -116,12 +116,12 @@ generate_hive_config() {
|
|||
|
||||
# return to the repo directory to copy the generated config from $TMPDIR
|
||||
popd 1> /dev/null
|
||||
mv "$tmpd/hive-deployment.yaml" ./hack/hive-config/
|
||||
mv "$tmpd/hive-deployment.yaml" ./hack/hive/hive-config/
|
||||
|
||||
if [ -d ./hack/hive-config/crds ]; then
|
||||
rm -rf ./hack/hive-config/crds
|
||||
if [ -d ./hack/hive/hive-config/crds ]; then
|
||||
rm -rf ./hack/hive/hive-config/crds
|
||||
fi
|
||||
cp -R "$tmpd/config/crds" ./hack/hive-config/
|
||||
cp -R "$tmpd/config/crds" ./hack/hive/hive-config/
|
||||
}
|
||||
|
||||
if [ ! -f go.mod ] || [ ! -d ".git" ]; then
|
Загрузка…
Ссылка в новой задаче