Skip to content

Instantly share code, notes, and snippets.

@katzefudder
Last active November 15, 2022 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katzefudder/659ad762bfb2b88b665514b4d4c3a2bf to your computer and use it in GitHub Desktop.
Save katzefudder/659ad762bfb2b88b665514b4d4c3a2bf to your computer and use it in GitHub Desktop.
kubectl run -n jgroups-demo ispn -it --rm=true --image=belaban/ispn_perf_test kube.sh
#!/bin/bash
# ---------------------------------------------------------------------
# This demo assumes that RBAC is enabled on the Kubernetes cluster.
#
# The serviceaccount, clusterrole and clusterrolebinding provide
# permission for the pods to query K8S api
# ---------------------------------------------------------------------
# Change to a Kubernetes namespace of your preference
export TARGET_NAMESPACE=jgroups-demo
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: $TARGET_NAMESPACE
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: jgroups-kubeping-service-account
namespace: $TARGET_NAMESPACE
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: jgroups-kubeping-pod-reader
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: jgroups-kubeping-api-access
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: jgroups-kubeping-pod-reader
subjects:
- kind: ServiceAccount
name: jgroups-kubeping-service-account
namespace: $TARGET_NAMESPACE
---
apiVersion: v1
items:
- apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
name: ispn-perf-test
namespace: $TARGET_NAMESPACE
spec:
replicas: 3
selector:
matchLabels:
run: ispn-perf-test
template:
metadata:
labels:
run: ispn-perf-test
spec:
serviceAccountName: jgroups-kubeping-service-account
containers:
- args:
- /opt/ispn/IspnPerfTest/bin/kube.sh
- -nohup
env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
image: belaban/ispn_perf_test
name: ispn-perf-test
resources: {}
terminationMessagePath: /dev/termination-log
kind: List
metadata: {}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment