1 Star 0 Fork 9

陈先生/Chaos-Mesh

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
install.sh 87.54 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051
#!/usr/bin/env bash
# Copyright 2021 Chaos Mesh 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.
#
# This is a script to quickly install chaos-mesh.
# This script will check if docker and kubernetes are installed. If local mode is set and kubernetes is not installed,
# it will use kind or minikube to install the kubernetes cluster according to the configuration.
# Finally, when all dependencies are installed, chaos-mesh will be installed.
VERSION=${VERSION:-latest}
usage() {
cat << EOF
This script is used to install chaos-mesh.
Before running this script, please ensure that:
* have installed docker if you run chaos-mesh in local.
* have installed Kubernetes if you run chaos-mesh in normal Kubernetes cluster
USAGE:
install.sh [FLAGS] [OPTIONS]
FLAGS:
-h, --help Prints help information
-d, --dependency-only Install dependencies only, including kind, kubectl, local-kube.
--force Force reinstall all components if they are already installed, include: kind, local-kube, chaos-mesh
--force-chaos-mesh Force reinstall chaos-mesh if it is already installed
--force-local-kube Force reinstall local Kubernetes cluster if it is already installed
--force-kubectl Force reinstall kubectl client if it is already installed
--force-kind Force reinstall Kind if it is already installed
--volume-provisioner Deploy volume provisioner in local Kubernetes cluster
--local-registry Deploy local docker registry in local Kubernetes cluster
--template Locally render templates
--k3s Install chaos-mesh in k3s environment
--microk8s Install chaos-mesh in microk8s environment
--host-network Install chaos-mesh using hostNetwork
OPTIONS:
-v, --version Version of chaos-mesh, default value: ${VERSION}
-l, --local [kind] Choose a way to run a local kubernetes cluster, supported value: kind,
If this value is not set and the Kubernetes is not installed, this script will exit with 1.
-n, --name Name of Kubernetes cluster, default value: kind
-c --crd The path of the crd files. Get the crd file from "https://mirrors.chaos-mesh.org" if the crd path is empty.
-r --runtime Runtime specifies which container runtime to use. Currently we only supports docker and containerd. default value: docker
--kind-version Version of the Kind tool, default value: v0.11.1
--node-num The count of the cluster nodes,default value: 3
--k8s-version Version of the Kubernetes cluster,default value: v1.17.2
--volume-num The volumes number of each kubernetes node,default value: 5
--release-name Release name of chaos-mesh, default value: chaos-mesh
--namespace Namespace of chaos-mesh, default value: chaos-mesh
--timezone Specifies timezone to be used by chaos-dashboard, chaos-daemon and controller.
EOF
}
main() {
local local_kube=""
local cm_version="${VERSION}"
local kind_name="kind"
local kind_version="v0.11.1"
local node_num=3
local k8s_version="v1.17.2"
local volume_num=5
local release_name="chaos-mesh"
local namespace="chaos-mesh"
local timezone="UTC"
local force_chaos_mesh=false
local force_local_kube=false
local force_kubectl=false
local force_kind=false
local volume_provisioner=false
local local_registry=false
local crd=""
local runtime="docker"
local template=false
local install_dependency_only=false
local k3s=false
local microk8s=false
local host_network=false
local docker_registry="ghcr.io"
while [[ $# -gt 0 ]]
do
key="$1"
case "$key" in
-h|--help)
usage
exit 0
;;
-l|--local)
local_kube="$2"
shift
shift
;;
-v|--version)
cm_version="$2"
shift
shift
;;
-n|--name)
kind_name="$2"
shift
shift
;;
-c|--crd)
crd="$2"
shift
shift
;;
-r|--runtime)
runtime="$2"
shift
shift
;;
-d|--dependency-only)
install_dependency_only=true
shift
;;
--force)
force_chaos_mesh=true
force_local_kube=true
force_kubectl=true
force_kind=true
shift
;;
--force-local-kube)
force_local_kube=true
shift
;;
--force-kubectl)
force_kubectl=true
shift
;;
--force-kind)
force_kind=true
shift
;;
--force-chaos-mesh)
force_chaos_mesh=true
shift
;;
--template)
template=true
shift
;;
--volume-provisioner)
volume_provisioner=true
shift
;;
--local-registry)
local_registry=true
shift
;;
--kind-version)
kind_version="$2"
shift
shift
;;
--node-num)
node_num="$2"
shift
shift
;;
--k8s-version)
k8s_version="$2"
shift
shift
;;
--volume-num)
volume_num="$2"
shift
shift
;;
--release-name)
release_name="$2"
shift
shift
;;
--namespace)
namespace="$2"
shift
shift
;;
--k3s)
k3s=true
shift
;;
--microk8s)
microk8s=true
shift
;;
--host-network)
host_network=true
shift
;;
--timezone)
timezone="$2"
shift
shift
;;
--docker-registry)
docker_registry="$2"
shift
shift
;;
*)
echo "unknown flag or option $key"
usage
exit 1
;;
esac
done
if [ "${runtime}" != "docker" ] && [ "${runtime}" != "containerd" ]; then
printf "container runtime %s is not supported\n" "${runtime}"
exit 1
fi
if [ "${local_kube}" != "" ] && [ "${local_kube}" != "kind" ]; then
printf "local Kubernetes by %s is not supported\n" "${local_kube}"
exit 1
fi
if [ "${local_kube}" == "kind" ]; then
runtime="containerd"
fi
if [ "${k3s}" == "true" ]; then
runtime="containerd"
fi
if [ "${microk8s}" == "true" ]; then
runtime="containerd"
fi
if [ "${crd}" == "" ]; then
crd="https://mirrors.chaos-mesh.org/${cm_version}/crd.yaml"
fi
if $template; then
ensure gen_crd_manifests "${crd}"
ensure gen_chaos_mesh_manifests "${runtime}" "${k3s}" "${cm_version}" "${timezone}" "${host_network}" "${docker_registry}" "${microk8s}"
exit 0
fi
need_cmd "sed"
need_cmd "tr"
if [ "${local_kube}" == "kind" ]; then
prepare_env
install_kubectl "${k8s_version}" ${force_kubectl}
check_docker
install_kind "${kind_version}" ${force_kind}
install_kubernetes_by_kind "${kind_name}" "${k8s_version}" "${node_num}" "${volume_num}" ${force_local_kube} ${volume_provisioner} ${local_registry}
fi
if [ "${install_dependency_only}" = true ]; then
exit 0
fi
check_kubernetes
install_chaos_mesh "${release_name}" "${namespace}" "${local_kube}" ${force_chaos_mesh} "${crd}" "${runtime}" "${k3s}" "${cm_version}" "${timezone}" "${docker_registry}" "${microk8s}"
ensure_pods_ready "${namespace}" "app.kubernetes.io/component=controller-manager" 100
ensure_pods_ready "${namespace}" "app.kubernetes.io/component=chaos-daemon" 100
ensure_pods_ready "${namespace}" "app.kubernetes.io/component=chaos-dashboard" 100
printf "Chaos Mesh %s is installed successfully\n" "${release_name}"
}
prepare_env() {
mkdir -p "$HOME/local/bin"
local set_path="export PATH=$HOME/local/bin:\$PATH"
local env_file="$HOME/.bash_profile"
if [[ ! -e "${env_file}" ]]; then
ensure touch "${env_file}"
fi
grep -qF -- "${set_path}" "${env_file}" || echo "${set_path}" >> "${env_file}"
ensure source "${env_file}"
}
check_kubernetes() {
need_cmd "kubectl"
kubectl_err_msg=$(kubectl version --output=yaml 2>&1 1>/dev/null)
if [ "$kubectl_err_msg" != "" ]; then
printf "check Kubernetes failed, error: %s\n" "${kubectl_err_msg}"
exit 1
fi
check_kubernetes_version
}
check_kubernetes_version() {
version_info=$(kubectl version --output=yaml | grep gitVersion | sed 's/.*gitVersion: v\([0-9.]*\).*/\1/g')
for v in $version_info
do
if version_lt "$v" "1.12.0"; then
printf "Chaos Mesh requires Kubernetes cluster running 1.12 or later\n"
exit 1
fi
done
}
install_kubectl() {
local kubectl_version=$1
local force_install=$2
printf "Install kubectl client\n"
err_msg=$(kubectl version --client=true --output=yaml 2>&1 1>/dev/null)
if [ "$err_msg" == "" ]; then
v=$(kubectl version --client=true --output=yaml | grep gitVersion | sed 's/.*gitVersion: v\([0-9.]*\).*/\1/g')
target_version=$(echo "${kubectl_version}" | sed s/v//g)
if version_lt "$v" "${target_version}"; then
printf "Chaos Mesg requires kubectl version %s or later\n" "${target_version}"
else
printf "kubectl Version %s has been installed\n" "$v"
if [ "$force_install" != "true" ]; then
return
fi
fi
fi
need_cmd "curl"
local KUBECTL_BIN="${HOME}/local/bin/kubectl"
local target_os=$(lowercase $(uname))
ensure curl -Lo /tmp/kubectl https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/${target_os}/amd64/kubectl
ensure chmod +x /tmp/kubectl
ensure mv /tmp/kubectl "${KUBECTL_BIN}"
}
install_kubernetes_by_kind() {
local cluster_name=$1
local cluster_version=$2
local node_num=$3
local volume_num=$4
local force_install=$5
local volume_provisioner=$6
local local_registry=$7
printf "Install local Kubernetes %s\n" "${cluster_name}"
need_cmd "kind"
work_dir=${HOME}/kind/${cluster_name}
kubeconfig_path=${work_dir}/config
data_dir=${work_dir}/data
clusters=$(kind get clusters)
cluster_exist=false
for c in $clusters
do
if [ "$c" == "$cluster_name" ]; then
printf "Kind cluster %s has been installed\n" "${cluster_name}"
cluster_exist=true
break
fi
done
if [ "$cluster_exist" == "true" ]; then
if [ "$force_install" == "true" ]; then
printf "Delete Kind Kubernetes cluster %s\n" "${cluster_name}"
kind delete cluster --name="${cluster_name}"
status=$?
if [ $status -ne 0 ]; then
printf "Delete Kind Kubernetes cluster %s failed\n" "${cluster_name}"
exit 1
fi
else
ensure kind get kubeconfig --name="${cluster_name}" > "${kubeconfig_path}"
return
fi
fi
ensure mkdir -p "${work_dir}"
printf "Clean data dir: %s\n" "${data_dir}"
if [ -d "${data_dir}" ]; then
ensure rm -rf "${data_dir}"
fi
config_file=${work_dir}/kind-config.yaml
cat <<EOF > "${config_file}"
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
kubeadmConfigPatches:
- |
kind: ClusterConfiguration
metadata:
name: config
apiServerExtraArgs:
enable-admission-plugins: NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 5000
hostPort: 5000
listenAddress: 127.0.0.1
protocol: TCP
EOF
for ((i=0;i<"${node_num}";i++))
do
ensure mkdir -p "${data_dir}/worker${i}"
cat <<EOF >> "${config_file}"
- role: worker
extraMounts:
EOF
for ((k=1;k<="${volume_num}";k++))
do
ensure mkdir -p "${data_dir}/worker${i}/vol${k}"
cat <<EOF >> "${config_file}"
- containerPath: /mnt/disks/vol${k}
hostPath: ${data_dir}/worker${i}/vol${k}
EOF
done
done
local kind_image="kindest/node:${cluster_version}"
printf "start to create kubernetes cluster %s" "${cluster_name}"
ensure kind create cluster --config "${config_file}" --image="${kind_image}" --name="${cluster_name}" --retain -v 1
ensure kind get kubeconfig --name="${cluster_name}" > "${kubeconfig_path}"
ensure export KUBECONFIG="${kubeconfig_path}"
if [ "$volume_provisioner" == "true" ]; then
deploy_volume_provisioner "${work_dir}"
fi
}
deploy_volume_provisioner() {
local data_dir=$1
local config_file=${data_dir}/local-volume-provisionser.yaml
volume_provisioner_image="quay.io/external_storage/local-volume-provisioner:v2.3.2"
cat <<EOF >"${config_file}"
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: "local-storage"
provisioner: "kubernetes.io/no-provisioner"
volumeBindingMode: "WaitForFirstConsumer"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: local-provisioner-config
namespace: kube-system
data:
nodeLabelsForPV: |
- kubernetes.io/hostname
storageClassMap: |
local-storage:
hostDir: /mnt/disks
mountDir: /mnt/disks
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: local-volume-provisioner
namespace: kube-system
labels:
app: local-volume-provisioner
spec:
selector:
matchLabels:
app: local-volume-provisioner
template:
metadata:
labels:
app: local-volume-provisioner
spec:
serviceAccountName: local-storage-admin
containers:
- image: ${volume_provisioner_image}
name: provisioner
securityContext:
privileged: true
env:
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: MY_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: JOB_CONTAINER_IMAGE
value: "quay.io/external_storage/local-volume-provisioner:v2.3.2"
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 100m
memory: 100Mi
volumeMounts:
- mountPath: /etc/provisioner/config
name: provisioner-config
readOnly: true
# mounting /dev in DinD environment would fail
# - mountPath: /dev
# name: provisioner-dev
- mountPath: /mnt/disks
name: local-disks
mountPropagation: "HostToContainer"
volumes:
- name: provisioner-config
configMap:
name: local-provisioner-config
# - name: provisioner-dev
# hostPath:
# path: /dev
- name: local-disks
hostPath:
path: /mnt/disks
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: local-storage-admin
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: local-storage-provisioner-pv-binding
namespace: kube-system
subjects:
- kind: ServiceAccount
name: local-storage-admin
namespace: kube-system
roleRef:
kind: ClusterRole
name: system:persistent-volume-provisioner
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: local-storage-provisioner-node-clusterrole
namespace: kube-system
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: local-storage-provisioner-node-binding
namespace: kube-system
subjects:
- kind: ServiceAccount
name: local-storage-admin
namespace: kube-system
roleRef:
kind: ClusterRole
name: local-storage-provisioner-node-clusterrole
apiGroup: rbac.authorization.k8s.io
EOF
ensure kubectl apply -f "${config_file}"
}
install_kind() {
local kind_version=$1
local force_install=$2
printf "Install Kind tool\n"
err_msg=$(kind version 2>&1 1>/dev/null)
if [ "$err_msg" == "" ]; then
v=$(kind version | awk '{print $2}' | sed s/v//g)
target_version=${kind_version//v}
if version_lt "$v" "${target_version}"; then
printf "Chaos Mesh requires Kind version %s or later\n" "${target_version}"
else
printf "Kind Version %s has been installed\n" "$v"
if [ "$force_install" != "true" ]; then
return
fi
fi
fi
local KIND_BIN="${HOME}/local/bin/kind"
local target_os=$(lowercase $(uname))
ensure curl -Lo /tmp/kind https://github.com/kubernetes-sigs/kind/releases/download/"$1"/kind-"${target_os}"-amd64
ensure chmod +x /tmp/kind
ensure mv /tmp/kind "$KIND_BIN"
}
install_chaos_mesh() {
local release_name=$1
local namespace=$2
local local_kube=$3
local force_install=$4
local crd=$5
local runtime=$6
local k3s=$7
local version=$8
local timezone=$9
local docker_registry=${10}
local microk8s=${11}
printf "Install Chaos Mesh %s\n" "${release_name}"
gen_crd_manifests "${crd}" | kubectl create --validate=false -f - || exit 1
gen_chaos_mesh_manifests "${runtime}" "${k3s}" "${version}" "${timezone}" "${host_network}" "${docker_registry}" "${microk8s}" | kubectl apply -f - || exit 1
}
version_lt() {
vercomp $1 $2
if [ $? == 2 ]; then
return 0
fi
return 1
}
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1 ver2
read -ra ver1 <<< "$1"
read -ra ver2 <<< "$2"
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}
check_docker() {
need_cmd "docker"
docker_err_msg=$(docker version 2>&1 1>/dev/null)
if [ "$docker_err_msg" != "" ]; then
printf "check docker failed:\n"
echo "$docker_err_msg"
exit 1
fi
}
say() {
printf 'install chaos-mesh: %s\n' "$1"
}
err() {
say "$1" >&2
exit 1
}
need_cmd() {
if ! check_cmd "$1"; then
err "need '$1' (command not found)"
fi
}
check_cmd() {
command -v "$1" > /dev/null 2>&1
}
lowercase() {
echo "$@" | tr "[A-Z]" "[a-z]"
}
# Run a command that should never fail. If the command fails execution
# will immediately terminate with an error showing the failing
# command.
ensure() {
if ! "$@"; then err "command failed: $*"; fi
}
ensure_pods_ready() {
local namespace=$1
local labels=""
local limit=$3
if [ "$2" != "" ]; then
labels="-l $2"
fi
count=0
while [ -n "$(kubectl get pods -n "${namespace}" ${labels} --no-headers | grep -v Running)" ];
do
echo "Waiting for pod running" && sleep 10;
kubectl get pods -n "${namespace}" ${labels} --no-headers | >&2 grep -v Running || true
((count=count+1))
if [ $count -gt $limit ]; then
printf "Waiting for pod status running timeout\n"
exit 1
fi
done
}
gen_crd_manifests() {
local crd=$1
if check_url "$crd"; then
need_cmd curl
ensure curl -sSL "$crd"
return
fi
ensure cat "$crd"
}
check_url() {
local url=$1
local regex='^(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]\.[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]$'
if [[ $url =~ $regex ]];then
return 0
else
return 1
fi
}
gen_chaos_mesh_manifests() {
local runtime=$1
local k3s=$2
local version=$3
local timezone=$4
local host_network=$5
local docker_registry=$6
local microk8s=$7
local socketDir="/var/run"
local socketName="docker.sock"
if [ "${runtime}" == "containerd" ]; then
socketDir="/run/containerd"
socketName="containerd.sock"
fi
if [ "${k3s}" == "true" ]; then
socketDir="/run/k3s/containerd"
socketName="containerd.sock"
fi
if [ "${microk8s}" == "true" ]; then
socketDir="/var/snap/microk8s/common/run"
socketName="containerd.sock"
fi
need_cmd mktemp
need_cmd openssl
need_cmd curl
K8S_SERVICE="chaos-mesh-controller-manager"
K8S_NAMESPACE="chaos-mesh"
VERSION_TAG="${version}"
IMAGE_REGISTRY_PREFIX="${docker_registry}"
tmpdir=$(mktemp -d)
ensure openssl genrsa -out ${tmpdir}/ca.key 2048 > /dev/null 2>&1
ensure openssl req -x509 -new -nodes -key ${tmpdir}/ca.key -subj "/CN=${K8S_SERVICE}.${K8S_NAMESPACE}.svc" -days 1875 -out ${tmpdir}/ca.crt > /dev/null 2>&1
ensure openssl genrsa -out ${tmpdir}/server.key 2048 > /dev/null 2>&1
cat <<EOF > ${tmpdir}/csr.conf
[req]
prompt = no
req_extensions = v3_req
distinguished_name = dn
[dn]
CN = ${K8S_SERVICE}.${K8S_NAMESPACE}.svc
[v3_req]
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = ${K8S_SERVICE}
DNS.2 = ${K8S_SERVICE}.${K8S_NAMESPACE}
DNS.3 = ${K8S_SERVICE}.${K8S_NAMESPACE}.svc
EOF
ensure openssl req -new -key ${tmpdir}/server.key -out ${tmpdir}/server.csr -config ${tmpdir}/csr.conf > /dev/null 2>&1
ensure openssl x509 -req -in ${tmpdir}/server.csr -CA ${tmpdir}/ca.crt -CAkey ${tmpdir}/ca.key -CAcreateserial -out ${tmpdir}/server.crt -days 1875 -extensions v3_req -extfile ${tmpdir}/csr.conf > /dev/null 2>&1
TLS_KEY=$(openssl base64 -A -in ${tmpdir}/server.key)
TLS_CRT=$(openssl base64 -A -in ${tmpdir}/server.crt)
CA_BUNDLE=$(openssl base64 -A -in ${tmpdir}/ca.crt)
# chaos-mesh.yaml start
cat <<EOF
---
apiVersion: v1
kind: Namespace
metadata:
name: chaos-mesh
---
# Source: chaos-mesh/templates/chaos-daemon-rbac.yaml
kind: ServiceAccount
apiVersion: v1
metadata:
namespace: "chaos-mesh"
name: chaos-daemon
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: chaos-daemon
---
# Source: chaos-mesh/templates/chaos-dashboard-rbac.yaml
# Copyright 2022 Chaos Mesh 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.
#
# ServiceAccount for component chaos-dashboard
kind: ServiceAccount
apiVersion: v1
metadata:
namespace: "chaos-mesh"
name: chaos-dashboard
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: chaos-dashboard
---
# Source: chaos-mesh/templates/controller-manager-rbac.yaml
# Copyright 2021 Chaos Mesh 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.
#
kind: ServiceAccount
apiVersion: v1
metadata:
namespace: "chaos-mesh"
name: chaos-controller-manager
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: controller-manager
---
# Source: chaos-mesh/templates/dns-rbac.yaml
# Copyright 2021 Chaos Mesh 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.
#
kind: ServiceAccount
apiVersion: v1
metadata:
namespace: "chaos-mesh"
name: chaos-dns-server
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: dns-server
---
# Source: chaos-mesh/templates/secrets-configuration.yaml
# Copyright 2021 Chaos Mesh 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.
#
kind: Secret
apiVersion: v1
metadata:
name: chaos-mesh-webhook-certs
namespace: "chaos-mesh"
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: webhook-secret
type: Opaque
data:
ca.crt: "${CA_BUNDLE}"
tls.crt: "${TLS_CRT}"
tls.key: "${TLS_KEY}"
---
# Source: chaos-mesh/templates/dns-configmap.yaml
# Copyright 2021 Chaos Mesh 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.
#
apiVersion: v1
kind: ConfigMap
metadata:
name: dns-server-config
namespace: "chaos-mesh"
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: chaos-dns-server
data:
Corefile: |
.:5353 {
errors
health {
lameduck 5s
}
ready
k8s_dns_chaos cluster.local in-addr.arpa ip6.arpa {
pods insecure
fallthrough in-addr.arpa ip6.arpa
ttl 30
grpcport 9288
}
prometheus :9153
forward . /etc/resolv.conf {
max_concurrent 1000
}
cache 30
loop
reload
loadbalance
}
---
# Source: chaos-mesh/templates/chaos-dashboard-rbac.yaml
# ClusterRole for chaos-dashboard at cluster scope
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-dashboard-cluster-level
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: chaos-dashboard
rules:
# chaos-dashboard could list namespace for selector hints
- apiGroups: [ "" ]
resources:
- namespaces
verbs:
- get
- list
- watch
# chaos-dashboard use subjectaccessreviews to authorize the requests
- apiGroups: [ "authorization.k8s.io" ]
resources:
- subjectaccessreviews
verbs:
- create
---
# Source: chaos-mesh/templates/chaos-dashboard-rbac.yaml
# ClusterRole for chaos-dashboard in target namespace
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-dashboard-target-namespace
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: chaos-dashboard
rules:
# chaos dashboard could list pods for selector hints
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- list
- watch
# chaos dashboard could record evnets from chaos experiments
- apiGroups:
- ""
resources:
- events
verbs:
- get
- list
- watch
# chaos dashboard could record and manipulate all the Chaos Mesh resources in target namespace
- apiGroups: [ "chaos-mesh.org" ]
resources:
- "*"
verbs: [ "*" ]
---
# Source: chaos-mesh/templates/controller-manager-rbac.yaml
# roles
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-controller-manager-target-namespace
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: controller-manager
rules:
- apiGroups: [ "" ]
resources: [ "pods", "configmaps", "secrets"]
verbs: [ "get", "list", "watch", "delete", "update", "patch" ]
- apiGroups:
- ""
resources:
- pods
verbs:
- "create"
- apiGroups:
- ""
resources:
- "pods/log"
verbs:
- "get"
- apiGroups:
- ""
resources:
- events
verbs:
- patch
- create
- watch
- list
- get
- apiGroups: [ "chaos-mesh.org" ]
resources:
- "*"
verbs: [ "*" ]
---
# Source: chaos-mesh/templates/controller-manager-rbac.yaml
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-controller-manager-cluster-level
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: controller-manager
rules:
- apiGroups: [ "" ]
resources:
- nodes
- persistentvolumes
- persistentvolumeclaims
- namespaces
- services
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "authorization.k8s.io" ]
resources:
- subjectaccessreviews
verbs: [ "create" ]
---
# Source: chaos-mesh/templates/dns-rbac.yaml
# roles
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-dns-server-target-namespace
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: dns-server
rules:
- apiGroups: [ "" ]
resources: [ "pods" ]
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "" ]
resources: [ "configmaps" ]
verbs: [ "*" ]
- apiGroups: [ "chaos-mesh.org" ]
resources:
- "*"
verbs: [ "*" ]
---
# Source: chaos-mesh/templates/dns-rbac.yaml
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-dns-server-cluster-level
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: dns-server
rules:
- apiGroups: [ "" ]
resources:
- namespaces
- services
- endpoints
- pods
verbs: [ "get", "list", "watch" ]
---
# Source: chaos-mesh/templates/chaos-dashboard-rbac.yaml
# ClusterRoleBinding for chaos-dashboard at cluster scope
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-dashboard-cluster-level
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: chaos-dashboard
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: chaos-mesh-chaos-dashboard-cluster-level
subjects:
- kind: ServiceAccount
name: chaos-dashboard
namespace: "chaos-mesh"
---
# Source: chaos-mesh/templates/chaos-dashboard-rbac.yaml
# binding ClusterRole to ServiceAccount for componnet chaos dashboard
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-dashboard-target-namespace
# TODO: notice that the targetNamespace is still defined as .Values.controllerManager.targetNamespace, .Values.targetNamespace would be better.
namespace: "chaos-mesh"
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: chaos-dashboard
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: chaos-mesh-chaos-dashboard-target-namespace
subjects:
- kind: ServiceAccount
name: chaos-dashboard
namespace: "chaos-mesh"
---
# Source: chaos-mesh/templates/controller-manager-rbac.yaml
# bindings cluster level
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-controller-manager-cluster-level
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: controller-manager
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: chaos-mesh-chaos-controller-manager-cluster-level
subjects:
- kind: ServiceAccount
name: chaos-controller-manager
namespace: "chaos-mesh"
---
# Source: chaos-mesh/templates/controller-manager-rbac.yaml
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-controller-manager-target-namespace
namespace: "chaos-mesh"
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: controller-manager
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: chaos-mesh-chaos-controller-manager-target-namespace
subjects:
- kind: ServiceAccount
name: chaos-controller-manager
namespace: "chaos-mesh"
---
# Source: chaos-mesh/templates/dns-rbac.yaml
# bindings cluster level
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-dns-server-cluster-level
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: dns-server
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: chaos-mesh-chaos-dns-server-cluster-level
subjects:
- kind: ServiceAccount
name: chaos-dns-server
namespace: "chaos-mesh"
---
# Source: chaos-mesh/templates/dns-rbac.yaml
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-dns-server-target-namespace
namespace:
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: dns-server
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: chaos-mesh-chaos-dns-server-target-namespace
subjects:
- kind: ServiceAccount
name: chaos-dns-server
namespace: "chaos-mesh"
---
# Source: chaos-mesh/templates/controller-manager-rbac.yaml
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-controller-manager-control-plane
namespace: "chaos-mesh"
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: controller-manager
rules:
- apiGroups: [ "" ]
resources: [ "services", "endpoints", "secrets" ]
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "authorization.k8s.io" ]
resources:
- subjectaccessreviews
verbs: [ "create" ]
- apiGroups: [ "" ]
resources: [ "pods/exec" ]
verbs: [ "create" ]
- apiGroups: [ "coordination.k8s.io" ]
resources: [ "leases" ]
verbs: [ "*" ]
- apiGroups: [ "" ]
resources: [ "configmaps" ]
verbs: [ "*" ]
---
# Source: chaos-mesh/templates/dns-rbac.yaml
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-dns-server-control-plane
namespace: "chaos-mesh"
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: dns-server
rules:
- apiGroups: [ "" ]
resources: [ "configmaps" ]
verbs: [ "get", "list" ]
---
# Source: chaos-mesh/templates/controller-manager-rbac.yaml
# binding for control plane namespace
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-controller-manager-control-plane
namespace: "chaos-mesh"
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: controller-manager
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: chaos-mesh-chaos-controller-manager-control-plane
subjects:
- kind: ServiceAccount
name: chaos-controller-manager
namespace: "chaos-mesh"
---
# Source: chaos-mesh/templates/dns-rbac.yaml
# binding for control plane namespace
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaos-mesh-chaos-dns-server-control-plane
namespace: "chaos-mesh"
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: dns-server
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: chaos-mesh-chaos-dns-server-control-plane
subjects:
- kind: ServiceAccount
name: chaos-dns-server
namespace: "chaos-mesh"
---
# Source: chaos-mesh/templates/chaos-daemon-service.yaml
# Copyright 2021 Chaos Mesh 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.
#
apiVersion: v1
kind: Service
metadata:
namespace: "chaos-mesh"
name: chaos-daemon
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "31766"
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: chaos-daemon
spec:
clusterIP: None
ports:
- name: grpc
port: 31767
targetPort: grpc
protocol: TCP
- name: http
port: 31766
targetPort: http
protocol: TCP
selector:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/component: chaos-daemon
---
# Source: chaos-mesh/templates/chaos-dashboard-deployment.yaml
apiVersion: v1
kind: Service
metadata:
namespace: "chaos-mesh"
name: chaos-dashboard
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/component: chaos-dashboard
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "2334"
spec:
selector:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/component: chaos-dashboard
type: NodePort
ports:
- protocol: TCP
port: 2333
targetPort: 2333
name: http
- protocol: TCP
port: 2334
targetPort: 2334
name: metric
---
# Source: chaos-mesh/templates/controller-manager-service.yaml
# Copyright 2021 Chaos Mesh 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.
#
apiVersion: v1
kind: Service
metadata:
namespace: "chaos-mesh"
name: chaos-mesh-controller-manager
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "10080"
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: controller-manager
spec:
type: ClusterIP
ports:
- port: 443
targetPort: webhook
protocol: TCP
name: webhook
- port: 10081
targetPort: pprof
protocol: TCP
name: pprof
- port: 10082
targetPort: ctrl
protocol: TCP
name: ctrl
- port: 10080
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/component: controller-manager
---
# Source: chaos-mesh/templates/dns-service.yaml
# Copyright 2021 Chaos Mesh 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.
#
apiVersion: v1
kind: Service
metadata:
name: chaos-mesh-dns-server
namespace: "chaos-mesh"
annotations:
prometheus.io/port: "9153"
prometheus.io/scrape: "true"
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: dns-server
spec:
selector:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/component: chaos-dns-server
ports:
- name: dns
port: 53
targetPort: 5353
protocol: UDP
- name: dns-tcp
port: 53
targetPort: 5353
protocol: TCP
- name: metrics
port: 9153
protocol: TCP
- name: grpc
port: 9288
protocol: TCP
---
# Source: chaos-mesh/templates/chaos-daemon-daemonset.yaml
# Copyright 2021 Chaos Mesh 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.
#
apiVersion: apps/v1
kind: DaemonSet
metadata:
namespace: "chaos-mesh"
name: chaos-daemon
labels:
app.kubernetes.io/component: chaos-daemon
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
spec:
selector:
matchLabels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/component: chaos-daemon
template:
metadata:
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: chaos-daemon
annotations:
spec:
hostNetwork: ${host_network}
serviceAccountName: chaos-daemon
hostPID: true
containers:
- name: chaos-daemon
image: ${IMAGE_REGISTRY_PREFIX}/chaos-mesh/chaos-daemon:${VERSION_TAG}
imagePullPolicy: IfNotPresent
command:
- /usr/local/bin/chaos-daemon
- --runtime
- ${runtime}
- --http-port
- !!str 31766
- --grpc-port
- !!str 31767
- --pprof
- --runtime-socket-path
- /host-run/${socketName}
env:
- name: TZ
value: ${timezone}
securityContext:
privileged: true
capabilities:
add:
- SYS_PTRACE
volumeMounts:
- name: socket-path
mountPath: /host-run
- name: sys-path
mountPath: /host-sys
- name: lib-modules
mountPath: /lib/modules
ports:
- name: grpc
containerPort: 31767
- name: http
containerPort: 31766
volumes:
- name: socket-path
hostPath:
path: ${socketDir}
- name: sys-path
hostPath:
path: /sys
- name: lib-modules
hostPath:
path: /lib/modules
---
# Source: chaos-mesh/templates/chaos-dashboard-deployment.yaml
# Copyright 2021 Chaos Mesh 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.
#
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: "chaos-mesh"
name: chaos-dashboard
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: chaos-dashboard
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/component: chaos-dashboard
template:
metadata:
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: chaos-dashboard
annotations:
spec:
securityContext:
{}
serviceAccountName: chaos-dashboard
containers:
- name: chaos-dashboard
image: ${IMAGE_REGISTRY_PREFIX}/chaos-mesh/chaos-dashboard:${VERSION_TAG}
imagePullPolicy: IfNotPresent
resources:
limits: {}
requests:
cpu: 25m
memory: 256Mi
command:
- /usr/local/bin/chaos-dashboard
env:
- name: CLEAN_SYNC_PERIOD
value: "12h"
- name: DATABASE_DATASOURCE
value: "/data/core.sqlite"
- name: DATABASE_DRIVER
value: "sqlite3"
- name: LISTEN_HOST
value: "0.0.0.0"
- name: LISTEN_PORT
value: "2333"
- name: METRIC_HOST
value: "0.0.0.0"
- name: METRIC_PORT
value: "2334"
- name: TTL_EVENT
value: "168h"
- name: TTL_EXPERIMENT
value: "336h"
- name: TTL_SCHEDULE
value: "336h"
- name: TTL_WORKFLOW
value: "336h"
- name: TZ
value: ${timezone}
- name: CLUSTER_SCOPED
value: "true"
- name: TARGET_NAMESPACE
value: "chaos-mesh"
- name: ENABLE_FILTER_NAMESPACE
value: "false"
- name: SECURITY_MODE
value: "false"
- name: GCP_SECURITY_MODE
value: "false"
- name: GCP_CLIENT_ID
value: ""
- name: GCP_CLIENT_SECRET
value: ""
- name: DNS_SERVER_CREATE
value: "true"
- name: ROOT_URL
value: "http://localhost:2333"
- name: ENABLE_PROFILING
value: "true"
volumeMounts:
- name: storage-volume
mountPath: /data
subPath: ""
ports:
- name: http
containerPort: 2333
- name: metric
containerPort: 2334
volumes:
- name: storage-volume
emptyDir: {}
---
# Source: chaos-mesh/templates/controller-manager-deployment.yaml
# Copyright 2021 Chaos Mesh 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.
#
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: "chaos-mesh"
name: chaos-controller-manager
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: controller-manager
spec:
replicas: 3
selector:
matchLabels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/component: controller-manager
template:
metadata:
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: controller-manager
annotations:
rollme: "install.sh"
spec:
securityContext:
{}
hostNetwork: ${host_network}
serviceAccountName: chaos-controller-manager
containers:
- name: chaos-mesh
image: ${IMAGE_REGISTRY_PREFIX}/chaos-mesh/chaos-mesh:${VERSION_TAG}
imagePullPolicy: IfNotPresent
resources:
limits: {}
requests:
cpu: 25m
memory: 256Mi
command:
- /usr/local/bin/chaos-controller-manager
env:
- name: METRICS_PORT
value: "10080"
- name: WEBHOOK_PORT
value: "10250"
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: TEMPLATE_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: ALLOW_HOST_NETWORK_TESTING
value: "false"
- name: TARGET_NAMESPACE
value: "chaos-mesh"
- name: CLUSTER_SCOPED
value: "true"
- name: TZ
value: ${timezone}
- name: CHAOS_DAEMON_SERVICE_PORT
value: !!str 31767
- name: BPFKI_PORT
value: !!str 50051
- name: ENABLED_CONTROLLERS
value: "*"
- name: ENABLED_WEBHOOKS
value: "*"
- name: TEMPLATE_LABELS
value: "app.kubernetes.io/component:template"
- name: CONFIGMAP_LABELS
value: "app.kubernetes.io/component:webhook"
- name: ENABLE_FILTER_NAMESPACE
value: "false"
- name: PPROF_ADDR
value: ":10081"
- name: CTRL_ADDR
value: ":10082"
- name: CHAOS_DNS_SERVICE_NAME
value: chaos-mesh-dns-server
- name: CHAOS_DNS_SERVICE_PORT
value: !!str 9288
- name: SECURITY_MODE
value: "false"
- name: CHAOSD_SECURITY_MODE
value: "false"
- name: POD_FAILURE_PAUSE_IMAGE
value: gcr.io/google-containers/pause:latest
- name: ENABLE_LEADER_ELECTION
value: "true"
- name: LEADER_ELECT_LEASE_DURATION
value: "15s"
- name: LEADER_ELECT_RENEW_DEADLINE
value: "10s"
- name: LEADER_ELECT_RETRY_PERIOD
value: "2s"
volumeMounts:
- name: webhook-certs
mountPath: /etc/webhook/certs
readOnly: true
ports:
- name: webhook
containerPort: 10250
- name: http
containerPort: 10080
- name: pprof
containerPort: 10081
- name: ctrl
containerPort: 10082
volumes:
- name: webhook-certs
secret:
secretName: chaos-mesh-webhook-certs
---
# Source: chaos-mesh/templates/dns-deployment.yaml
# Copyright 2021 Chaos Mesh 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.
#
apiVersion: apps/v1
kind: Deployment
metadata:
name: chaos-dns-server
namespace: "chaos-mesh"
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: chaos-dns-server
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/component: chaos-dns-server
template:
metadata:
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: chaos-dns-server
spec:
serviceAccountName: chaos-dns-server
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/component
operator: In
values:
- chaos-dns-server
topologyKey: kubernetes.io/hostname
weight: 100
priorityClassName:
containers:
- name: chaos-dns-server
image: ghcr.io/chaos-mesh/chaos-coredns:v0.2.6
imagePullPolicy: IfNotPresent
resources:
limits: {}
requests:
cpu: 100m
memory: 70Mi
args: [ "-conf", "/etc/chaos-dns/Corefile" ]
volumeMounts:
- name: config-volume
mountPath: /etc/chaos-dns
readOnly: true
ports:
- containerPort: 5353
name: dns
protocol: UDP
- containerPort: 5353
name: dns-tcp
protocol: TCP
- containerPort: 9153
name: metrics
protocol: TCP
- containerPort: 9288
name: grpc
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 60
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 5
readinessProbe:
httpGet:
path: /ready
port: 8181
scheme: HTTP
securityContext:
allowPrivilegeEscalation: false
capabilities:
add:
- NET_BIND_SERVICE
drop:
- all
readOnlyRootFilesystem: true
dnsPolicy: Default
volumes:
- name: config-volume
configMap:
name: dns-server-config
items:
- key: Corefile
path: Corefile
---
# Source: chaos-mesh/templates/cert-manager-certs.yaml
# Copyright 2022 Chaos Mesh 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.
#
---
# Source: chaos-mesh/templates/chaos-daemon-rbac.yaml
# Copyright 2021 Chaos Mesh 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.
#
---
# Source: chaos-mesh/templates/chaos-dashboard-pvc.yaml
# Copyright 2021 Chaos Mesh 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.
#
---
# Source: chaos-mesh/templates/ingress.yaml
# Copyright 2021 Chaos Mesh 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.
#
---
# Source: chaos-mesh/templates/prometheus-configmap.yaml
# Copyright 2021 Chaos Mesh 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.
#
---
# Source: chaos-mesh/templates/prometheus-deployment.yaml
# Copyright 2021 Chaos Mesh 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.
#
---
# Source: chaos-mesh/templates/prometheus-rbac.yaml
# Copyright 2021 Chaos Mesh 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.
#
---
# Source: chaos-mesh/templates/prometheus-service.yaml
# Copyright 2021 Chaos Mesh 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.
#
---
# Source: chaos-mesh/templates/mutating-admission-webhooks.yaml
# Copyright 2022 Chaos Mesh 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.
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: chaos-mesh-mutation
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: admission-webhook
webhooks:
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-podchaos
failurePolicy: Fail
name: mpodchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- podchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-iochaos
failurePolicy: Fail
name: miochaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- iochaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-timechaos
failurePolicy: Fail
name: mtimechaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- timechaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-networkchaos
failurePolicy: Fail
name: mnetworkchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- networkchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-kernelchaos
failurePolicy: Fail
name: mkernelchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- kernelchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-stresschaos
failurePolicy: Fail
name: mstresschaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- stresschaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-awschaos
failurePolicy: Fail
name: mawschaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- awschaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-azurechaos
failurePolicy: Fail
name: mazurechaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- azurechaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-gcpchaos
failurePolicy: Fail
name: mgcpchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- gcpchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-dnschaos
failurePolicy: Fail
name: mdnschaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- dnschaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-jvmchaos
failurePolicy: Fail
name: mjvmchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- jvmchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-schedule
failurePolicy: Fail
name: mschedule.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- schedules
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-workflow
failurePolicy: Fail
name: mworkflow.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- workflows
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-httpchaos
failurePolicy: Fail
name: mhttpchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- httpchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-blockchaos
failurePolicy: Fail
name: mblockchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- blockchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-physicalmachinechaos
failurePolicy: Fail
name: mphysicalmachinechaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- physicalmachinechaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-physicalmachine
failurePolicy: Fail
name: mphysicalmachine.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- physicalmachines
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-statuscheck
failurePolicy: Fail
name: mstatuscheck.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- statuschecks
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /mutate-chaos-mesh-org-v1alpha1-remotecluster
failurePolicy: Fail
name: mremotecluster.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- remotecluster
---
# Source: chaos-mesh/templates/validating-admission-webhooks.yaml
# Copyright 2022 Chaos Mesh 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.
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: chaos-mesh-validation
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: admission-webhook
webhooks:
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-podchaos
failurePolicy: Fail
name: vpodchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- podchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-iochaos
failurePolicy: Fail
name: viochaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- iochaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-timechaos
failurePolicy: Fail
name: vtimechaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- timechaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-networkchaos
failurePolicy: Fail
name: vnetworkchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- networkchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-kernelchaos
failurePolicy: Fail
name: vkernelchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- kernelchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-stresschaos
failurePolicy: Fail
name: vstresschaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- stresschaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-awschaos
failurePolicy: Fail
name: vawschaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- awschaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-azurechaos
failurePolicy: Fail
name: vazurechaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- azurechaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-gcpchaos
failurePolicy: Fail
name: vgcpchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- gcpchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-dnschaos
failurePolicy: Fail
name: vdnschaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- dnschaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-jvmchaos
failurePolicy: Fail
name: vjvmchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- jvmchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-schedule
failurePolicy: Fail
name: vschedule.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- schedules
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-workflow
failurePolicy: Fail
name: vworkflow.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- workflows
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-httpchaos
failurePolicy: Fail
name: vhttpchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- httpchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-blockchaos
failurePolicy: Fail
name: vblockchaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- blockchaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-physicalmachinechaos
failurePolicy: Fail
name: vphysicalmachinechaos.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- physicalmachinechaos
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-physicalmachine
failurePolicy: Fail
name: vphysicalmachine.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- physicalmachines
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-statuscheck
failurePolicy: Fail
name: vstatuscheck.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- statuschecks
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-chaos-mesh-org-v1alpha1-remotecluster
failurePolicy: Fail
name: vremotecluster.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- remotecluster
---
# Source: chaos-mesh/templates/validating-admission-webhooks.yaml
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: chaos-mesh-validation-auth
labels:
app.kubernetes.io/name: chaos-mesh
app.kubernetes.io/instance: chaos-mesh
app.kubernetes.io/part-of: chaos-mesh
app.kubernetes.io/version: ${VERSION_TAG##v}
app.kubernetes.io/component: admission-webhook
webhooks:
- clientConfig:
caBundle: "${CA_BUNDLE}"
service:
name: chaos-mesh-controller-manager
namespace: "chaos-mesh"
path: /validate-auth
failurePolicy: Fail
name: vauth.kb.io
timeoutSeconds: 5
sideEffects: None
admissionReviewVersions: ["v1", "v1beta1"]
rules:
- apiGroups:
- chaos-mesh.org
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources: [ "*" ]
EOF
# chaos-mesh.yaml end
}
main "$@" || exit 1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/future1980/Chaos-Mesh.git
git@gitee.com:future1980/Chaos-Mesh.git
future1980
Chaos-Mesh
Chaos-Mesh
master

搜索帮助