Skip to content

Commit

Permalink
Bump dependencies (#220)
Browse files Browse the repository at this point in the history
* Bump dependencies
  • Loading branch information
worldtiki authored Jul 29, 2021
1 parent 1bba8dd commit 3a31519
Show file tree
Hide file tree
Showing 11 changed files with 542 additions and 174 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
########################
### Builder ###
########################
FROM golang:1.15 as builder
FROM golang:1.16 as builder
RUN mkdir -p /kube-monkey
COPY ./ /kube-monkey/
WORKDIR /kube-monkey
Expand Down
27 changes: 8 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[![Build](https://github.com/asobti/kube-monkey/actions/workflows/go.yml/badge.svg)](https://github.com/asobti/kube-monkey/actions/workflows/go.yml)
[![Publish Docker image](https://github.com/asobti/kube-monkey/actions/workflows/docker-build-push.yml/badge.svg)](https://github.com/asobti/kube-monkey/actions/workflows/docker-build-push.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/asobti/kube-monkey)](https://goreportcard.com/report/github.com/asobti/kube-monkey)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Docker Pulls](https://img.shields.io/docker/pulls/ayushsobti/kube-monkey?label=Docker%20pulls&logo=docker)](https://hub.docker.com/r/ayushsobti/kube-monkey/)
Expand Down Expand Up @@ -46,7 +45,7 @@ that belong to a k8s app as Pods inherit labels from their k8s app. So, if kube-

```yaml
---
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: monkey-victim
Expand All @@ -67,7 +66,7 @@ For newer versions of kubernetes you may need to add the labels to the k8s app m

```yaml
---
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: monkey-victim
Expand Down Expand Up @@ -226,13 +225,8 @@ See dir [`examples/`](https://github.com/asobti/kube-monkey/tree/master/examples


**Helm Chart**
A helm chart is provided that assumes you have already compiled and uploaded the container to your own container repository. Once uploaded, you need to edit the value of `image.repository` to point at the location of your container, by default it is pointed to `ayushsobti/kube-monkey`.

Helm can then be executed using default values
```bash
helm install --name $release helm/kubemonkey
```
refer [kube-monkey helm chart README.md](https://github.com/asobti/kube-monkey/blob/master/helm/kubemonkey/README.md)
See [How to install kube-monkey with Helm](helm/kubemonkey/README.md).

## Logging

Expand All @@ -254,15 +248,7 @@ kube-monkey uses [glog](github.com/golang/glog) and supports all command-line fe
More resources: See the [k8s logging page](https://kubernetes.io/docs/concepts/cluster-administration/logging/) suggesting [community conventions for logging severity](https://github.com/kubernetes/community/blob/master/contributors/devel/logging.md)

## Compatibility with Kubernetes

kube-monkey is built using v7.0 of [kubernetes/client-go](https://github.com/kubernetes/client-go). Refer to the
[Compatibility Matrix](https://github.com/kubernetes/client-go#compatibility-matrix) to see which
versions of Kubernetes are compatible.

## Instructions on how to get this working on OpenShift

### OpenShift 3.x
## Instructions on how to get this working on OpenShift 3.x

```
git clone https://github.com/asobti/kube-monkey.git
Expand Down Expand Up @@ -292,4 +278,7 @@ oc set volume dc/kube-monkey --add --name=kubeconfigmap -m /etc/kube-monkey -t c

## Ways to contribute

See [How to Contribute](https://github.com/asobti/kube-monkey/blob/master/CONTRIBUTING.md)
See [How to Contribute](CONTRIBUTING.md)

## License
This project is licensed under the Apache License v2.0 - see the [LICENSE](LICENSE) file for details.
20 changes: 7 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
module kube-monkey

go 1.15
go 1.16

require (
bou.ke/monkey v1.0.2
github.com/fsnotify/fsnotify v1.4.7
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367 // indirect
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/fsnotify/fsnotify v1.4.9
github.com/golang/glog v0.0.0-20210429001901-424d2337a529
github.com/pkg/errors v0.9.1
github.com/spf13/viper v1.7.1
github.com/stretchr/objx v0.1.2-0.20180531200725-0ab728f62c7f // indirect
github.com/spf13/viper v1.8.1
github.com/stretchr/testify v1.7.0
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
gopkg.in/inf.v0 v0.9.0 // indirect
k8s.io/api v0.0.0-20180308224125-73d903622b73
k8s.io/apimachinery v0.0.0-20180228050457-302974c03f7e
k8s.io/client-go v7.0.0+incompatible
k8s.io/api v0.21.3
k8s.io/apimachinery v0.21.3
k8s.io/client-go v0.21.3
)
597 changes: 486 additions & 111 deletions go.sum

Large diffs are not rendered by default.

33 changes: 19 additions & 14 deletions helm/kubemonkey/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
# Kube-Monkey Helm Chart

[Kube-Monkey](https://github.com/asobti/kube-monkey) periodically kills pods in your Kubernetes cluster,that are opt-in based on their own rules.
[Kube-Monkey](https://github.com/asobti/kube-monkey) periodically kills pods in your Kubernetes cluster, that are opt-in based on their own rules.

## Official Helm
## Add repository

TBA to official helm charts,There is no official helm chart yet for kube-monkey.
```bash
helm repo add kubemonkey https://asobti.github.io/kube-monkey/charts/repo
helm repo update
```

## Installing the Chart

To install the chart with the release name `my-release`:

```console
$ git clone https://github.com/asobti/kube-monkey
$ cd kube-monkey/helm
$ helm install --name my-release kubemonkey
With Helm v3

```bash
helm install my-release kubemonkey/kube-monkey --version 1.4.0
```

With Helm v2

```bash
helm install --name my-release kubemonkey/kube-monkey --version 1.4.0
```
**Note:** by default kube-monkey installed in default namespace, which can be overridden by passing --namespace=name

The command deploys kube-monkey on the Kubernetes cluster in the default configuration. The [configurations](#Configurations) section lists the parameters that can be configured during installation.

## Uninstalling the Chart

To uninstall/delete the my-release deployment:
To uninstall/delete the `my-release` deployment:

```console
$ helm delete my-release --purge
$ helm delete my-release
```

The command removes all the Kubernetes components associated with the chart and deletes the release.
Expand Down Expand Up @@ -121,7 +129,7 @@ rbac:
enabled: true
image:
repository: ayushsobti/kube-monkey
tag: v0.3.0
tag: v0.4.0
pullPolicy: IfNotPresent
config:
dryRun: false
Expand All @@ -131,9 +139,6 @@ config:
blacklistedNamespaces: [ "kube-system" ]
whitelistedNamespaces: [ "namespace1", "namespace2" ]
timeZone: America/New_York
debug:
enabled: true # if you want to enable debugging and see how pods killed immediately set this to true
schedule_immediate_kill: true
args:
logLevel: 5
logDir: /var/log/kube-monkey
Expand Down
2 changes: 1 addition & 1 deletion helm/kubemonkey/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ metadata:
---

{{- if .Values.rbac.enabled -}}
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "kubemonkey.fullname" . }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package daemonsets
//All these functions require api access specific to the version of the app

import (
"context"
"fmt"
"strconv"

Expand All @@ -18,7 +19,7 @@ import (

// EligibleDaemonSets gets all eligible daemonsets that opted in (filtered by config.EnabledLabel)
func EligibleDaemonSets(clientset kube.Interface, namespace string, filter *metav1.ListOptions) (eligVictims []victims.Victim, err error) {
enabledVictims, err := clientset.AppsV1().DaemonSets(namespace).List(*filter)
enabledVictims, err := clientset.AppsV1().DaemonSets(namespace).List(context.TODO(), *filter)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -47,7 +48,7 @@ func EligibleDaemonSets(clientset kube.Interface, namespace string, filter *meta

// IsEnrolled checks if the daemonset is currently enrolled in kube-monkey
func (d *DaemonSet) IsEnrolled(clientset kube.Interface) (bool, error) {
daemonset, err := clientset.AppsV1().DaemonSets(d.Namespace()).Get(d.Name(), metav1.GetOptions{})
daemonset, err := clientset.AppsV1().DaemonSets(d.Namespace()).Get(context.TODO(), d.Name(), metav1.GetOptions{})
if err != nil {
return false, err
}
Expand All @@ -56,7 +57,7 @@ func (d *DaemonSet) IsEnrolled(clientset kube.Interface) (bool, error) {

// KillType returns current killtype config label for update
func (d *DaemonSet) KillType(clientset kube.Interface) (string, error) {
daemonset, err := clientset.AppsV1().DaemonSets(d.Namespace()).Get(d.Name(), metav1.GetOptions{})
daemonset, err := clientset.AppsV1().DaemonSets(d.Namespace()).Get(context.TODO(), d.Name(), metav1.GetOptions{})
if err != nil {
return "", err
}
Expand All @@ -71,7 +72,7 @@ func (d *DaemonSet) KillType(clientset kube.Interface) (string, error) {

// KillValue returns current killvalue config label for update
func (d *DaemonSet) KillValue(clientset kube.Interface) (int, error) {
daemonset, err := clientset.AppsV1().DaemonSets(d.Namespace()).Get(d.Name(), metav1.GetOptions{})
daemonset, err := clientset.AppsV1().DaemonSets(d.Namespace()).Get(context.TODO(), d.Name(), metav1.GetOptions{})
if err != nil {
return -1, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package deployments
//All these functions require api access specific to the version of the app

import (
"context"
"fmt"
"strconv"

Expand All @@ -18,7 +19,7 @@ import (

// EligibleDeployments gets all eligible deployments that opted in (filtered by config.EnabledLabel)
func EligibleDeployments(clientset kube.Interface, namespace string, filter *metav1.ListOptions) (eligVictims []victims.Victim, err error) {
enabledVictims, err := clientset.AppsV1().Deployments(namespace).List(*filter)
enabledVictims, err := clientset.AppsV1().Deployments(namespace).List(context.TODO(), *filter)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -47,7 +48,7 @@ func EligibleDeployments(clientset kube.Interface, namespace string, filter *met

// IsEnrolled checks if the deployment is currently enrolled in kube-monkey
func (d *Deployment) IsEnrolled(clientset kube.Interface) (bool, error) {
deployment, err := clientset.AppsV1().Deployments(d.Namespace()).Get(d.Name(), metav1.GetOptions{})
deployment, err := clientset.AppsV1().Deployments(d.Namespace()).Get(context.TODO(), d.Name(), metav1.GetOptions{})
if err != nil {
return false, err
}
Expand All @@ -56,7 +57,7 @@ func (d *Deployment) IsEnrolled(clientset kube.Interface) (bool, error) {

// KillType returns current killtype config label for update
func (d *Deployment) KillType(clientset kube.Interface) (string, error) {
deployment, err := clientset.AppsV1().Deployments(d.Namespace()).Get(d.Name(), metav1.GetOptions{})
deployment, err := clientset.AppsV1().Deployments(d.Namespace()).Get(context.TODO(), d.Name(), metav1.GetOptions{})
if err != nil {
return "", err
}
Expand All @@ -71,7 +72,7 @@ func (d *Deployment) KillType(clientset kube.Interface) (string, error) {

// KillValue returns current killvalue config label for update
func (d *Deployment) KillValue(clientset kube.Interface) (int, error) {
deployment, err := clientset.AppsV1().Deployments(d.Namespace()).Get(d.Name(), metav1.GetOptions{})
deployment, err := clientset.AppsV1().Deployments(d.Namespace()).Get(context.TODO(), d.Name(), metav1.GetOptions{})
if err != nil {
return -1, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package statefulsets
//All these functions require api access specific to the version of the app

import (
"context"
"fmt"
"strconv"

Expand All @@ -18,7 +19,7 @@ import (

// EligibleStatefulSets gets all eligible statefulsets that opted in (filtered by config.EnabledLabel)
func EligibleStatefulSets(clientset kube.Interface, namespace string, filter *metav1.ListOptions) (eligVictims []victims.Victim, err error) {
enabledVictims, err := clientset.AppsV1().StatefulSets(namespace).List(*filter)
enabledVictims, err := clientset.AppsV1().StatefulSets(namespace).List(context.TODO(), *filter)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -47,7 +48,7 @@ func EligibleStatefulSets(clientset kube.Interface, namespace string, filter *me

// IsEnrolled checks if the statefulset is currently enrolled in kube-monkey
func (ss *StatefulSet) IsEnrolled(clientset kube.Interface) (bool, error) {
statefulset, err := clientset.AppsV1().StatefulSets(ss.Namespace()).Get(ss.Name(), metav1.GetOptions{})
statefulset, err := clientset.AppsV1().StatefulSets(ss.Namespace()).Get(context.TODO(), ss.Name(), metav1.GetOptions{})
if err != nil {
return false, err
}
Expand All @@ -56,7 +57,7 @@ func (ss *StatefulSet) IsEnrolled(clientset kube.Interface) (bool, error) {

// KillType returns current killtype config label for update
func (ss *StatefulSet) KillType(clientset kube.Interface) (string, error) {
statefulset, err := clientset.AppsV1().StatefulSets(ss.Namespace()).Get(ss.Name(), metav1.GetOptions{})
statefulset, err := clientset.AppsV1().StatefulSets(ss.Namespace()).Get(context.TODO(), ss.Name(), metav1.GetOptions{})
if err != nil {
return "", err
}
Expand All @@ -71,7 +72,7 @@ func (ss *StatefulSet) KillType(clientset kube.Interface) (string, error) {

// KillValue returns current killvalue config label for update
func (ss *StatefulSet) KillValue(clientset kube.Interface) (int, error) {
statefulset, err := clientset.AppsV1().StatefulSets(ss.Namespace()).Get(ss.Name(), metav1.GetOptions{})
statefulset, err := clientset.AppsV1().StatefulSets(ss.Namespace()).Get(context.TODO(), ss.Name(), metav1.GetOptions{})
if err != nil {
return -1, err
}
Expand Down
5 changes: 3 additions & 2 deletions internal/pkg/victims/victims.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package victims

import (
"context"
"fmt"
"math"
"math/rand"
Expand Down Expand Up @@ -118,7 +119,7 @@ func (v *VictimBase) Pods(clientset kube.Interface) ([]corev1.Pod, error) {
return nil, err
}

podlist, err := clientset.CoreV1().Pods(v.namespace).List(*labelSelector)
podlist, err := clientset.CoreV1().Pods(v.namespace).List(context.TODO(), *labelSelector)
if err != nil {
return nil, err
}
Expand All @@ -133,7 +134,7 @@ func (v *VictimBase) DeletePod(clientset kube.Interface, podName string) error {
}

deleteOpts := v.GetDeleteOptsForPod()
return clientset.CoreV1().Pods(v.namespace).Delete(podName, deleteOpts)
return clientset.CoreV1().Pods(v.namespace).Delete(context.TODO(), podName, *deleteOpts)
}

// Creates the DeleteOptions object
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/victims/victims_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package victims

import (
"context"
"fmt"
"strings"
"testing"
Expand Down Expand Up @@ -63,7 +64,7 @@ func newVictimBase() *VictimBase {
}

func getPodList(client kube.Interface) *corev1.PodList {
podList, _ := client.CoreV1().Pods(NAMESPACE).List(metav1.ListOptions{})
podList, _ := client.CoreV1().Pods(NAMESPACE).List(context.TODO(), metav1.ListOptions{})
return podList
}

Expand Down

0 comments on commit 3a31519

Please sign in to comment.