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

Support in cluster context #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ConnorsApps
Copy link

Adds the ability to run knsiff in a Kubernetes pod.

Testing

manifest.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: sniff-service-account
  namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: sniff-cluster-role
rules:
- apiGroups: [""]
  resources: ["*"]
  verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: sniff-cluster-role-binding
subjects:
- kind: ServiceAccount
  name: sniff-service-account
  namespace: default
roleRef:
  kind: ClusterRole
  name: sniff-cluster-role
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: Pod
metadata:
  name: sniff
spec:
  serviceAccountName: sniff-service-account
  containers:
  - name: sniff
    image: golang:1-alpine
    command: ["tail", "-f", "/dev/null"]
  restartPolicy: Never
# create pod with overly permissive rbac rules
kubectl apply -f manifest.yaml

# Copy local repo
kubectl cp . sniff:/app -c sniff

kubectl exec sniff -c sniff -- sh -c "cd /app && go mod download"

kubectl exec sniff -c sniff -- sh -c "cd /app && go run cmd/kubectl-sniff.go pod-name -c container -n my-namespace -p -o -"

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.

1 participant