Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Simplified Merge-All #33

Merged
merged 43 commits into from
Jan 24, 2018
Merged

Simplified Merge-All #33

merged 43 commits into from
Jan 24, 2018

Conversation

Aergonus
Copy link
Collaborator

@Aergonus Aergonus commented Jan 3, 2018

Aggregates #18, #19, #24, #25, #27, #28, #29, #30, #31, #34

added some extra guiding instructions
Technically shouldn't force the user to use the kube-monkey namespace
Had to run `glide cache-clear` and then `glide update --strip-vendor`
Allow people to copy pasta ;)
asobti#23
CreateClient involves creating a clientset that accesses the k8 api
It does not belong in chaos but rather kubernetes
New sublocation for all kinds
run with make gofmt
standardized variables to loc
added timezone for debugging printing
specified format printout for schedule
addresses asobti#21 and asobti#23
Possible after templatizing in asobti#27 and reference issue #10
Allow victims to do the heavylifting for common methods
Whitelists and Blacklists both operate.
Blacklist overrides a whitelist.
@Aergonus
Copy link
Collaborator Author

deploy-test.yaml

---
apiVersion: v1
kind: Namespace
metadata:
  name: test-system
---
  apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: counter
    namespace: test-system
  spec:
    replicas: 2
    template:
      metadata:
        labels:
          kube-monkey/enabled: enabled
          kube-monkey/identifier: monkey-victim-counter
          kube-monkey/mtbf: "1"
          kube-monkey/kill-mode: "kill-all"
      spec:
        containers:
        - args:
          - /bin/sh
          - -c
          - 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done'
          image: busybox:latest
          imagePullPolicy: Always
          name: test-counter
        restartPolicy: Always
---
  apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: counter-delete-all-fail-test
    namespace: test-system
  spec:
    replicas: 2
    template:
      metadata:
        labels:
          kube-monkey/enabled: enabled
          kube-monkey/identifier: monkey-victim-delete-all-fail-test
          kube-monkey/mtbf: "1"
          kube-monkey/kill-mode: "kill-all"
      spec:
        containers:
        - args:
          - /bin/sh
          - -c
          - 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done'
          image: DOESNOTEXIST:latest
          imagePullPolicy: Always
          name: test-counter-delete-all-fail-test
        restartPolicy: Always
---
  apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: singlecounter
    namespace: test-system
  spec:
    replicas: 1
    template:
      metadata:
        labels:
          kube-monkey/enabled: enabled
          kube-monkey/identifier: monkey-victim-single-counter
          kube-monkey/mtbf: "2"
          kube-monkey/kill-mode: "fixed"
          kube-monkey/kill-value: "2"
      spec:
        containers:
        - args:
          - /bin/sh
          - -c
          - 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done'
          image: busybox:latest
          imagePullPolicy: Always
          name: test-single-counter
        restartPolicy: Always
---
  apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: opt-out-counter
    namespace: test-system
  spec:
    replicas: 1
    template:
      metadata:
        labels:
          kube-monkey/enabled: disabled
          kube-monkey/identifier: not-a-counter-victim
          kube-monkey/mtbf: "1"
          kube-monkey/kill-mode: "kill-all"
      spec:
        containers:
        - args:
          - /bin/sh
          - -c
          - 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 86400; done'
          image: busybox:latest
          imagePullPolicy: Always
          name: not-a-counter-victim
        restartPolicy: Always
---
  apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: fail-deploy
    namespace: test-system
  spec:
    replicas: 2
    template:
      metadata:
        labels:
          kube-monkey/enabled: enabled
          kube-monkey/identifier: failure-test
          kube-monkey/mtbf: "1"
          kube-monkey/kill-mode: "fixed"
          kube-monkey/kill-value: "2"
      spec:
        containers:
        - args:
          - /bin/sh
          - -c
          - 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 300; done'
          image: invalidimage
          imagePullPolicy: Always
          name: fail-deploy
        restartPolicy: Always
---
# missing-secret.yaml
# a failed deployment
  apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: secret-pod
    namespace: test-system
  spec:
    replicas: 2
    template:
      metadata:
        labels:
          kube-monkey/enabled: enabled
          kube-monkey/identifier: missing-secret-test
          kube-monkey/mtbf: "1"
          kube-monkey/kill-mode: "random-max-percent"
          kube-monkey/kill-value: "2"
      spec:
        containers:
          - name: missing-secret-test
            image: busybox:latest
            command: [ "/bin/sh", "-c", "env" ]
            volumeMounts:
              - mountPath: /etc/secret/
                name: myothersecret
        volumes:
          - name: myothersecret
            secret:
              secretName: myothersecret
        restartPolicy: Always

ss-test.yaml

---
apiVersion: v1
kind: Namespace
metadata:
  name: test-system
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: counter-ss
  name: counter-ss
  namespace: test-system
spec:
  clusterIP: None
  ports:
  - port: 9001
  selector:
    app: counter-ss
---
  apiVersion: apps/v1beta1
  kind: StatefulSet
  metadata:
    name: counter-ss
    namespace: test-system
  spec:
    serviceName: counter-ss
    replicas: 3
    template:
      metadata:
        labels:
          kube-monkey/enabled: enabled
          kube-monkey/identifier: monkey-victim-counter-ss
          kube-monkey/mtbf: "1"
          kube-monkey/kill-mode: "kill-all"
      spec:
        containers:
        - args:
          - /bin/sh
          - -c
          - 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done'
          image: busybox:latest
          imagePullPolicy: Always
          name: test-counter-ss
        restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: counter-delete-all-fail-test-ss
  name: counter-delete-all-fail-test-ss
  namespace: test-system
spec:
  clusterIP: None
  ports:
  - port: 9002
  selector:
    app: counter-delete-all-fail-test-ss
---
  apiVersion: apps/v1beta1
  kind: StatefulSet
  metadata:
    name: counter-delete-all-fail-test-ss
    namespace: test-system
  spec:
    serviceName: counter-delete-all-fail-test-ss
    replicas: 3
    template:
      metadata:
        labels:
          kube-monkey/enabled: enabled
          kube-monkey/identifier: monkey-victim-delete-all-fail-test-ss
          kube-monkey/mtbf: "1"
          kube-monkey/kill-mode: "kill-all"
      spec:
        containers:
        - args:
          - /bin/sh
          - -c
          - 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done'
          image: DOESNOTEXIST:latest
          imagePullPolicy: Always
          name: test-counter-delete-all-fail-test-ss
        restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: singlecounter-ss
  name: singlecounter-ss
  namespace: test-system
spec:
  clusterIP: None
  ports:
  - port: 9003
  selector:
    app: singlecounter-ss
---
  apiVersion: apps/v1beta1
  kind: StatefulSet
  metadata:
    name: singlecounter-ss
    namespace: test-system
  spec:
    serviceName: singlecounter-ss
    replicas: 1
    template:
      metadata:
        labels:
          kube-monkey/enabled: enabled
          kube-monkey/identifier: monkey-victim-single-counter-ss
          kube-monkey/mtbf: "2"
          kube-monkey/kill-mode: "fixed"
          kube-monkey/kill-value: "2"
      spec:
        containers:
        - args:
          - /bin/sh
          - -c
          - 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done'
          image: busybox:latest
          imagePullPolicy: Always
          name: test-single-counter-ss
        restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: opt-out-counter-ss
  name: opt-out-counter-ss
  namespace: test-system
spec:
  clusterIP: None
  ports:
  - port: 9004
  selector:
    app: opt-out-counter-ss
---
  apiVersion: apps/v1beta1
  kind: StatefulSet
  metadata:
    name: opt-out-counter-ss
    namespace: test-system
  spec:
    serviceName: opt-out-counter-ss
    replicas: 1
    template:
      metadata:
        labels:
          kube-monkey/enabled: disabled
          kube-monkey/identifier: not-a-counter-victim-ss
          kube-monkey/mtbf: "1"
          kube-monkey/kill-mode: "kill-all"
      spec:
        containers:
        - args:
          - /bin/sh
          - -c
          - 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 86400; done'
          image: busybox:latest
          imagePullPolicy: Always
          name: not-a-counter-victim-ss
        restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: fail-deploy-ss
  name: fail-deploy-ss
  namespace: test-system
spec:
  clusterIP: None
  ports:
  - port: 9005
  selector:
    app: fail-deploy-ss
---
  apiVersion: apps/v1beta1
  kind: StatefulSet
  metadata:
    name: fail-deploy-ss
    namespace: test-system
  spec:
    serviceName: fail-deploy-ss
    replicas: 2
    template:
      metadata:
        labels:
          kube-monkey/enabled: enabled
          kube-monkey/identifier: failure-test-ss
          kube-monkey/mtbf: "1"
          kube-monkey/kill-mode: "random-max-percent"
          kube-monkey/kill-value: "75"
      spec:
        containers:
        - args:
          - /bin/sh
          - -c
          - 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 300; done'
          image: invalidimage
          imagePullPolicy: Always
          name: fail-deploy-ss
        restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: secret-pod-ss
  name: secret-pod-ss
  namespace: test-system
spec:
  clusterIP: None
  ports:
  - port: 9006
  selector:
    app: secret-pod-ss
---
# missing-secret.yaml
# a failed deployment
  apiVersion: apps/v1beta1
  kind: StatefulSet
  metadata:
    name: secret-pod-ss
    namespace: test-system
  spec:
    serviceName: secret-pod-ss
    replicas: 2
    template:
      metadata:
        labels:
          kube-monkey/enabled: enabled
          kube-monkey/identifier: missing-secret-test-ss
          kube-monkey/mtbf: "1"
          kube-monkey/kill-mode: "random-max-percent"
          kube-monkey/kill-value: "75"
      spec:
        containers:
          - name: missing-secret-test-ss
            image: busybox:latest
            command: [ "/bin/sh", "-c", "env" ]
            volumeMounts:
              - mountPath: /etc/secret/
                name: myothersecret
        volumes:
          - name: myothersecret
            secret:
              secretName: myothersecret
        restartPolicy: Always

config.toml

  config.toml: |
    [kubemonkey]
    dry_run = false
    time_zone = "America/New_York"
    run_hour = 8
    start_hour = 10
    end_hour = 16
    graceperiod_sec = 10
    blacklisted_namespaces = ["kube-system"]
    whitelisted_namespaces = ["default", "test-system"]
    [debug]
    enabled = false
    schedule_delay = 10
    force_should_kill = false
    schedule_immediate_kill = true

@Aergonus
Copy link
Collaborator Author

I just updated the glide.lock by rewriting it (y)

chaos/chaos.go Outdated
return c.DeletePod(client, targetPod)
}
// Has the victim been removed from the whitelist since scheduling?
if !c.Victim().IsWhitelisted() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Spellchaser Does this mean that each victim has to specifically be listed in the whitelist for kube-monkey to act on it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the default for whitelisting is all namespaces. So if you don't enable a whitelist, it doesn't affect you.

Copy link
Collaborator Author

@Aergonus Aergonus Jan 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose a better comment would be something like
// Does the namespace whitelist still include the victim's namespace now at killtime?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the default is NamespaceDefault

viper.SetDefault(param.WhitelistedNamespaces, []string{metav1.NamespaceDefault})

Is that the same as NamespaceAll?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nada, NamespaceDefault is "default" NamespaceAll is ""
I figured it'd be safer, abliet more confusing for users

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if I don't specify the whitelisted_namespaces in my config file, my victims will not be killed (assuming they are in their own namespace) ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, ignore that. I saw the following commit where you update docs for the whitelisting stuff and that clears it up.

@asobti asobti merged commit aa8fc3a into asobti:master Jan 24, 2018
@Aergonus
Copy link
Collaborator Author

Aergonus commented Jan 24, 2018 via email

This was referenced Jan 24, 2018
@Aergonus Aergonus deleted the master branch January 24, 2018 14:44
@Aergonus Aergonus restored the master branch January 24, 2018 14:45
@Aergonus Aergonus deleted the master branch January 24, 2018 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants