I've been working with Kafka for over 7 years. I inevitably find myself doing the same set of activities while I'm developing or working with someone else's system. Here's a set of Kafka productivity hacks for doing a few things way faster than you're probably doing them now. 🔥
This file contains 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
oc project kubernauts | |
podname=$(oc get pods | grep postgres-$(oc get dc postgres -o jsonpath='{.status.latestVersion}') | grep -v deploy | grep Running | awk '{print $1}') | |
oc rsh -c postgres $podname | |
OR | |
oc get pods | grep postgres | |
oc exec -it postgres-pod-name bash | |
This file contains 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: apps/v1 | |
kind: Deployment | |
metadata: | |
labels: | |
run: alpine | |
name: alpine | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: |
This file contains 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
cattle-aws: | |
request_spot_instances: false | |
spot_price: | |
root_disk_size: 20 | |
iam_instance_profile_name: "rancher-controlplane-role" | |
iam_instance_profile_worker: # specify if overlap_cp_etcd_worker is false and existing_vpc is true | |
rancher_cluster_name: "cattle-aws-cluster" | |
rancher_api_url: "https://rancher.xyz.com/v3" | |
rancher_access_key: | |
rancher_secret_key: |
This file contains 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
export TF_VAR_rancher_access_key=token-xyz123 | |
export TF_VAR_rancher_secret_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
export TF_VAR_AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxx | |
export TF_VAR_AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxx | |
export TF_VAR_AWS_DEFAULT_REGION=eu-central-1 | |
export AWS_DEFAULT_REGION=eu-central-1 | |
export AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
This file contains 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: kafka-topics | |
namespace: aceme-confluent-dev # change it | |
labels: | |
app.kubernetes.io/component: kafka-topics | |
spec: | |
ports: | |
- port: 8082 |
This file contains 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: apps/v1 | |
kind: Deployment | |
metadata: | |
labels: | |
run: utils | |
name: utils | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: |
This file contains 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
Q: Is it possible to create a custom role, where a non-admin user which has only view rights to run “oc rsh” command to only a certain pod or in a project to all pods? | |
A: you can define a custom role which allows only rsh permission (pods/exec): | |
create a yaml file like this: my-custom-role.yaml | |
``` | |
apiVersion: authorization.openshift.io/v1 | |
kind: ClusterRole | |
metadata: | |
name: rsh-pod |
This file contains 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
alias util='kubectl get nodes --no-headers | awk '\''{print $1}'\'' | xargs -I {} sh -c '\''echo {} ; kubectl describe node {} | grep Allocated -A 5 | grep -ve Event -ve Allocated -ve percent -ve -- ; echo '\''' | |
util |
This file contains 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
#!/bin/bash | |
set -euo pipefail | |
echo -e "Iterating...\n" | |
nodes=$(kubectl get node --no-headers -o custom-columns=NAME:.metadata.name) | |
for node in $nodes; do | |
echo "Node: $node" | |
kubectl describe node "$node" | sed '1,/Non-terminated Pods/d' |