blob: f2672868da3fb8d150c39d5d084c5a7aadc28695 [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
version: '3'
env:
KUBECONFIG:
sh: |-
if test -e $OPS_TMP/kubeconfig
then echo $OPS_TMP/kubeconfig
else echo ~/.kube/config
fi
tasks:
prereq:
silent: true
cmds:
- test -n "$AKS_PROJECT" || die 'Please, configure AKS with "ops config aks"'
- az version || die 'You need to install and configure az cli tool before running this command.'
- config AKS_PREREQ_OK="true"
status:
- config AKS_PREREQ_OK
update-yaml:
cmds:
- curl -L https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml >cert-manager.yaml
- curl -L "https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/cloud/deploy.yaml" >ingress-deploy.yaml
kubeconfig:
desc: extract the kubeconfig to access
silent: true
cmds:
- task: prereq
- >
retry -t 20 -m 600 az aks get-credentials --name $AKS_NAME --resource-group $AKS_PROJECT --overwrite-existing -f "$OPS_TMP/kubeconfig_$AKS_NAME" 2>/dev/null
- cp "$OPS_TMP/kubeconfig_$AKS_NAME" "$OPS_TMP/aks-$AKS_NAME.kubeconfig"
config:
desc: configure an Azure AKS kubernetes cluster
silent: true
cmds:
- $OPS config aks
create:
silent: true
desc: create an Azure AKS kubernetes cluster
cmds:
- task: prereq
- az account set --subscription "$(az account show --query 'id' -o tsv)"
- >
az group show -a "$AKS_PROJECT" 2>/dev/null
|| az group create --name "$AKS_PROJECT" --location "$AKS_REGION"
- >
az aks show -g "$AKS_PROJECT" -n "$AKS_NAME" 2>/dev/null
|| az aks create
-g "$AKS_PROJECT" -n "$AKS_NAME"
--enable-managed-identity
--node-count "$AKS_COUNT"
--node-osdisk-size="$AKS_DISK"
--node-vm-size="$AKS_VM"
--ssh-key-value="$AKS_SSHKEY"
- task: kubeconfig
- task: ingress
- task: certman
- config OPERATOR_CONFIG_KUBE=auto
delete:
silent: true
desc: delete the current Azure AKS cluster
cmds:
- echo "*** Deleting the $AKS_NAME cluster"
- az account set --subscription $(az account show --query 'id' -o tsv)
- az aks delete --name $AKS_NAME --resource-group $AKS_PROJECT
- rm "$OPS_TMP/kubeconfig" "$OPS_TMP/aks-$AKS_NAME.kubeconfig"
certman:
cmds:
- |
if test -z "{{.DEL}}"
then retry -t 1000 -m 1800 kubectl --kubeconfig "$OPS_TMP/kubeconfig" apply -f cert-manager.yaml
else kubectl apply -f cert-manager.yaml
fi
ingress:
cmds:
- |
if test -z "{{.DEL}}"
then retry -t 1000 -m 1800 kubectl --kubeconfig "$OPS_TMP/kubeconfig" apply -f ingress-deploy.yaml
else kubectl delete -f ingress-deploy.yaml
fi
lb:
silent: true
desc: show the load balancer
cmds:
- task: kubeconfig
- >
kubectl -n ingress-nginx get svc/ingress-nginx-controller
-o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null
|| die "load balancer not found"
- echo ""
status:
silent: true
desc: show the cluster status
cmds:
- task: prereq
- az aks show -n $AKS_NAME -g $AKS_PROJECT -o table