Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(istio): draft files for tutorial #11

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash
#
# Copyright Istio Authors
#
# 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.

SCRIPTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# only ask if in interactive mode
if [[ -t 0 && -z ${NAMESPACE} ]];then
echo -n "namespace ? [default] "
read -r NAMESPACE
fi

# verify if the namespace exists, otherwise use default namespace
if [[ -n ${NAMESPACE} ]];then
ns=$(kubectl get namespace "${NAMESPACE}" --no-headers --output=go-template="{{.metadata.name}}" 2>/dev/null)
if [[ -z ${ns} ]];then
echo "NAMESPACE ${NAMESPACE} not found."
NAMESPACE=default
fi
fi

# if no namespace is provided, use default namespace
if [[ -z ${NAMESPACE} ]];then
NAMESPACE=default
fi

echo "using NAMESPACE=${NAMESPACE}"

# clean up Istio traffic management resources that may have been used
protos=( destinationrules virtualservices gateways )
for proto in "${protos[@]}"; do
for resource in $(kubectl get -n ${NAMESPACE} "$proto" -o name); do
kubectl delete -n ${NAMESPACE} "$resource";
done
done

# clean up Gateway API resources that may have been used
if kubectl get crd gateways.gateway.networking.k8s.io >/dev/null 2>&1; then
protos=( httproutes gateways.gateway.networking.k8s.io )
for proto in "${protos[@]}"; do
for resource in $(kubectl get -n ${NAMESPACE} "$proto" -o name); do
kubectl delete -n ${NAMESPACE} "$resource";
done
done
kubectl delete -n ${NAMESPACE} -f "$SCRIPTDIR/bookinfo-versions.yaml" >/dev/null 2>&1
fi

OUTPUT=$(mktemp)
export OUTPUT
echo "Application cleanup may take up to one minute"
kubectl delete -n ${NAMESPACE} -f "$SCRIPTDIR/bookinfo.yaml" > "${OUTPUT}" 2>&1
ret=$?
function cleanup() {
rm -f "${OUTPUT}"
}

trap cleanup EXIT

if [[ ${ret} -eq 0 ]];then
cat "${OUTPUT}"
else
# ignore NotFound errors
OUT2=$(grep -v NotFound "${OUTPUT}")
if [[ -n ${OUT2} ]];then
cat "${OUTPUT}"
exit ${ret}
fi
fi

# wait for 30 sec for bookinfo to clean up
sleep 30

echo "Application cleanup successful"
109 changes: 0 additions & 109 deletions deploy-webhook.yml

This file was deleted.

103 changes: 22 additions & 81 deletions deploy.yml
Original file line number Diff line number Diff line change
@@ -1,93 +1,34 @@
---
# deployment.yaml
version: v1
kind: kubernetes
application: cdaas-sample-app
# Map of Deployment Targets, this is set up in a way where
# we can do multi-target deployments (multi-region or multi-cluster)
application: reviews
targets:
# This in the name of a deployment. Underneath it is its configuration.
test:
# the agentIdentifier of the Remote Network Agent for this target
account: sample-rna-test-cluster
# Optionally override the namespaces that are in the manifests
namespace: sample-test
# This is the key to a strategy under the strategies map
strategy: rolling
staging:
# the agentIdentifier of the Remote Network Agent for this target
account: sample-rna-staging-cluster
# Optionally override the namespaces that are in the manifests
namespace: sample-staging
# This is the key to a strategy under the strategies map
strategy: rolling
constraints:
dependsOn: ["test"]
beforeDeployment: []
prod-eu:
# the agentIdentifier of the Remote Network Agent for this target
account: sample-rna-prod-eu-cluster
# Optionally override the namespaces that are in the manifests
namespace: sample-prod-eu
# This is the key to a strategy under the strategies map
strategy: mybluegreen
constraints:
dependsOn: ["staging"]
beforeDeployment:
- pause:
untilApproved: true
prod-us:
# the agentIdentifier of the Remote Network Agent for this target
account: sample-rna-prod-us-cluster
# Optionally override the namespaces that are in the manifests
namespace: sample-prod-us
# This is the key to a strategy under the strategies map
strategy: mycanary
constraints:
dependsOn: ["staging"]
beforeDeployment:
- pause:
untilApproved: true
# The list of manifests sources
dev:
account: aimeeu-local
namespace: istiodemo
strategy: strategy1
manifests:
# This reads all YAML files in a dir
# and deploys manifests in that dir to all targets.
- path: manifests/sample-app.yml
# The map of strategies, a deployment target will reference one of these
- path: manifests/reviews-v1.yaml
strategies:
# this is the name for the strategy
mycanary:
# This map key is the deployment strategy type
strategy1:
canary:
steps:
# The map key is the step type
- setWeight:
weight: 25
- pause:
duration: 10
unit: seconds
- setWeight:
weight: 50
weight: 10
- pause:
duration: 10
unit: seconds
- setWeight:
weight: 100
rolling:
canary:
steps:
untilApproved: true
- setWeight:
weight: 100
mybluegreen:
# This specifies the deployment strategy type
blueGreen:
activeService: cdaas-sample-app-svc
# List of what needs to happen before redirecting traffic
redirectTrafficAfter:
- pause:
duration: 10
unit: seconds
# List of what needs to happen before shutting down the old version
shutDownOldVersionAfter:
weight: 57
- pause:
duration: 20
unit: seconds
untilApproved: true
trafficManagement:
- targets: ["dev"]
istio:
- virtualService:
name: reviews-route # virtualService.metadata.name
httpRouteName: reviews-http-route # virtualService.http.route[].name abstraction
destinationRule: # OPTIONAL (if only one destination exists on the service) virtualService.http.route[].destination/destinationRule abstraction
name: reviews-destination #destinationRule.metadata.name
activeSubsetName: stable # OPTIONAL (if only 1 active subset on DR)- virtualService.http.route[].destinations[0].subset
canarySubsetName: canary
Loading