在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):chaostoolkit/chaostoolkit-kubernetes开源软件地址(OpenSource Url):https://github.com/chaostoolkit/chaostoolkit-kubernetes开源编程语言(OpenSource Language):Python 99.7%开源软件介绍(OpenSource Introduction):Chaos Toolkit Extensions for KubernetesThis project contains activities, such as probes and actions, you can call from your experiment through the Chaos Toolkit to perform Chaos Engineering against the Kubernetes API: killing a pod, removing a statefulset or node... InstallTo be used from your experiment, this package must be installed in the Python environment where chaostoolkit already lives.
UsageTo use the probes and actions from this package, add the following to your experiment file: {
"title": "Do we remain available in face of pod going down?",
"description": "We expect Kubernetes to handle the situation gracefully when a pod goes down",
"tags": ["kubernetes"],
"steady-state-hypothesis": {
"title": "Verifying service remains healthy",
"probes": [
{
"name": "all-our-microservices-should-be-healthy",
"type": "probe",
"tolerance": true,
"provider": {
"type": "python",
"module": "chaosk8s.probes",
"func": "microservice_available_and_healthy",
"arguments": {
"name": "myapp"
}
}
}
]
},
"method": [
{
"type": "action",
"name": "terminate-db-pod",
"provider": {
"type": "python",
"module": "chaosk8s.pod.actions",
"func": "terminate_pods",
"arguments": {
"label_selector": "app=my-app",
"name_pattern": "my-app-[0-9]$",
"rand": true
}
},
"pauses": {
"after": 5
}
}
]
} That's it! Notice how the action gives you the way to kill one pod randomly. Please explore the documentation to see existing probes and actions. ConfigurationUse ~/.kube/configIf you have a valid entry in your You may specify
Specify the Kubernetes contextQuite often, your Kubernetes configuration contains several entries and you need to define the one to use as a default context when not it isn't explicitely provided. You may of course change your default using
{
"title": "Do we remain available in face of pod going down?",
"description": "We expect Kubernetes to handle the situation gracefully when a pod goes down",
"tags": ["kubernetes"],
"secrets": {
"k8s": {
"KUBERNETES_CONTEXT": "..."
}
},
"steady-state-hypothesis": {
"title": "Verifying service remains healthy",
"probes": [
{
"name": "all-our-microservices-should-be-healthy",
"type": "probe",
"tolerance": true,
"secrets": ["k8s"],
"provider": {
"type": "python",
"module": "chaosk8s.probes",
"func": "microservice_available_and_healthy",
"arguments": {
"name": "myapp"
}
}
}
]
},
"method": [
{
"type": "action",
"name": "terminate-db-pod",
"secrets": ["k8s"],
"provider": {
"type": "python",
"module": "chaosk8s.pod.actions",
"func": "terminate_pods",
"arguments": {
"label_selector": "app=my-app",
"name_pattern": "my-app-[0-9]$",
"rand": true
}
},
"pauses": {
"after": 5
}
}
]
} You need to specify the Use a Pod's service accountWhen running from a pod (not your local machine or a CI for instance), the
To let the extension know about this, simply set env:
- name: CHAOSTOOLKIT_IN_POD
value: "true" Pass all credentials in the experimentFinally, you may pass explicitely all required credentials information to the experiment as follows: Using an API key{
"secrets": {
"kubernetes": {
"KUBERNETES_HOST": "http://somehost",
"KUBERNETES_API_KEY": {
"type": "env",
"key": "SOME_ENV_VAR"
}
}
}
} Using a username/password{
"secrets": {
"kubernetes": {
"KUBERNETES_HOST": "http://somehost",
"KUBERNETES_USERNAME": {
"type": "env",
"key": "SOME_ENV_VAR"
},
"KUBERNETES_PASSWORD": {
"type": "env",
"key": "SOME_ENV_VAR"
}
}
}
} Using a TLS key/certificate{
"secrets": {
"kubernetes": {
"KUBERNETES_HOST": "http://somehost",
"KUBERNETES_CERT_FILE": {
"type": "env",
"key": "SOME_ENV_VAR"
},
"KUBERNETES_KEY_FILE": {
"type": "env",
"key": "SOME_ENV_VAR"
}
}
}
} Managed Kubernetes Clusters AuthenticationOn some managed Kubernetes clusters, you also need to authenticate against the platform itself because the Kubernetes authentication is delegated to it. Google Cloud PlatformIn addition to your Kubernetes credentials (via the
But can also be achieved by defining the ContributeIf you wish to contribute more functions to this package, you are more than
welcome to do so. Please, fork this project, write unit tests to cover the proposed changes,
implement the changes, ensure they meet the formatting standards set out by Please refer to the formatting section for more information on the formatting standards. The Chaos Toolkit projects require all contributors must sign a Developer Certificate of Origin on each commit they would like to merge into the master branch of the repository. Please, make sure you can abide by the rules of the DCO before submitting a PR. DevelopIf you wish to develop on this project, make sure to install the development dependencies. But first, create a virtual environment and then install those dependencies. $ make install-dev Now, you can edit the files and they will be automatically be seen by your
environment, even when running from the TestsTo run the tests for the project execute the following: $ make tests Formatting and LintingWe use a combination of Before raising a Pull Request, we recommend you run formatting against your code with: $ make format This will automatically format any code that doesn't adhere to the formatting standards. As some things are not picked up by the formatting, we also recommend you run: $ make lint To ensure that any unused import statements/strings that are too long, etc. are also picked up. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论