This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: mongodb-0 | |
labels: | |
app.kubernetes.io/name: mongodb | |
app.kubernetes.io/component: mongodb | |
spec: | |
type: ClusterIP | |
clusterIP: None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make target | |
port-forward: | |
while true; do \ | |
kubectl port-forward -n my-ns service/mongodb-0 27017:27017 & \ | |
kubectl port-forward -n my-ns service/mongodb-1 27011:27017 & \ | |
kubectl port-forward -n my-ns service/mongodb-2 27012:27017 & \ | |
kubectl port-forward -n my-ns service/mongodb-3 27013:27017 & \ | |
kubectl port-forward -n my-ns service/mongodb-arbiter-0 27014:27017 \ | |
done; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from locust import User, task, constant, tag | |
from pymongo import MongoClient | |
from time import perf_counter | |
class Mongo: | |
conn = "" | |
def __init__(self): | |
cs = 'mongodb://mongodb-0:27017,mongodb-1:27011,mongodb-2:27012,mongodb-3:27013,mongodb-arbiter-0:27014' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from argparse import ArgumentParser | |
import sys as _sys | |
# Tested on Python 3.8. For version >=3.9, There is new exit_on_error flag in init function. | |
# Although it doesn't entirely help our use case, we should be passing our flag `exit_on_error` | |
# to the parent class init function. | |
class CustomArgumentParser(ArgumentParser): | |
def __init__(self, prog=None, exit_on_error=False): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CustomArgumentParser | |
from io import StringIO | |
import sys | |
parser = CustomArgumentParser(description='Process my command') | |
parser.add_argument('foo', type=str, help='Magic of foo') | |
parser.add_argument( | |
'--bar', | |
action='store', | |
required=False, | |
type=str, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: ClusterRole | |
metadata: | |
labels: | |
rbac.authorization.k8s.io/aggregate-to-view: "true" | |
name: view-role-extras | |
rules: | |
- apiGroups: | |
- autoscaling | |
resources: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ kubectl get clusterrole view -o yaml | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: ClusterRole | |
metadata: | |
annotations: | |
rbac.authorization.kubernetes.io/autoupdate: "true" | |
labels: | |
kubernetes.io/bootstrapping: rbac-defaults | |
rbac.authorization.k8s.io/aggregate-to-edit: "true" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ k get ns foo-bar -o yaml | |
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: foo-bar | |
selfLink: /api/v1/namespaces/foo-bar | |
spec: | |
finalizers: | |
- kubernetes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
NAMESPACE=<your-rogue-namespace> | |
kubectl proxy & | |
kubectl get namespace $NAMESPACE -o json |jq '.spec = {"finalizers":[]}' > temp.json | |
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE/finalize | |
pkill -9 -f "kubectl proxy" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ( | |
// conditionTypes Namespace condition types that are maintained by namespace_deleter controller. | |
conditionTypes = []v1.NamespaceConditionType{ | |
v1.NamespaceDeletionDiscoveryFailure, | |
v1.NamespaceDeletionGVParsingFailure, | |
v1.NamespaceDeletionContentFailure, | |
v1.NamespaceContentRemaining, | |
v1.NamespaceFinalizersRemaining, | |
} | |
okMessages = map[v1.NamespaceConditionType]string{ |