Skip to content

Instantly share code, notes, and snippets.

@ipedrazas
ipedrazas / gist:c93f255a17785a7eb7f2fd83af4c21a9
Last active March 28, 2019 12:30
service analysis - iptables

-> % svcs -n twistlock

NAME                TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                      AGE
twistlock-console   ClusterIP   10.103.43.18   <none>        8084/TCP,8083/TCP,8081/TCP   18h

-> % k get ep -n twistlock

NAME                ENDPOINTS                                                  AGE
twistlock-console   10.103.129.17:8081,10.103.129.17:8084,10.103.129.17:8083   18h
@ipedrazas
ipedrazas / gist:6edbd57ae813e999e78c475fbd6c3fe6
Created February 22, 2019 06:55
Add ServiceAccount to Deploymetn/Pod
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
@ipedrazas
ipedrazas / gist:403df2ed30ea8682e2b709ddc1c24bcf
Created January 23, 2019 20:24
curl internal service kubernetes kubectl proxy
# To call from outside the cluster a service type `ClusterIP`
# We use `kubectl proxy`
kubectl proxy
# Then, the service can be accessed by calling:
curl http://localhost:8001/api/v1/namespaces/status/services/x01-kstatus-api:5000/proxy/api/jobs
# This is
# curl http://localhost:8001/api/v1/namespaces/[NAMESPACE]/services/[SERVICE:PORT]/proxy/[QUERY_STRING]
livenessProbe:
exec:
command:
- /bin/sh
- -c
- |-
FATAL_ERRORS=$( echo "${LIVENESS_PROBE_FATAL_ERRORS}" | grep -q '\S' && \
grep -F "${LIVENESS_PROBE_FATAL_ERRORS}" /tmp/.liveness_probe )
cp /dev/null /tmp/.liveness_probe
if [ ! -z "${FATAL_ERRORS}" ]; then
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
kubectl get po -a --all-namespaces -o json | \
jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) |
"kubectl delete po \(.metadata.name) -n \(.metadata.namespace) --grace-period=0 --force " ' | xargs -n 1 bash -c
pinn(){
kubectl get pods --all-namespaces --field-selector spec.nodeName=$1 -o wide
}
@ipedrazas
ipedrazas / gist:b58c17fd10116b6d39935a6f11365214
Created December 4, 2018 20:09
Curl to artifactory to publish helm package
@curl --user $(PUBLISH_REPO_USER):$(PUBLISH_REPO_PWD) --upload-file $(PACKAGE) $(PUBLISH_REPO_URL)/$(PUBLISH_REPO_PATH)
@ipedrazas
ipedrazas / list-images.sh
Created November 15, 2018 17:44
List docker images in a Kubernetes cluster
#!/bin/bash
IMAGES=()
# Get helm releases
helm ls -q | while read i; do
echo "Processing release $i";
# Get docker images per release
helm get "$i" | grep "image: \"" | awk '{print $2}';
done
@ipedrazas
ipedrazas / gist:b3a0c75be5e4d680cc412bf98e7a859c
Created October 30, 2018 11:46
Openstack instance types
Name VCPUS RAM Total Disk Root Disk Ephemeral Disk Public
m1.small 1 8 GB 50 GB 50 GB 0 GB Yes
d1.medium 2 16 GB 1.07 TB 100 GB 1000 GB Yes
d1.large 4 32 GB 1.07 TB 100 GB 1000 GB Yes
d1.xlarge 8 64 GB 1.07 TB 100 GB 1000 GB Yes
m1.medium 2 16 GB 100 GB 100 GB 0 GB Yes
m1.large 4 32 GB 200 GB 200 GB 0 GB Yes
m1.xlarge 8 64 GB 400 GB 400 GB 0 GB Yes
m1.2xl 16 128 GB 800 GB 800 GB 0 GB Yes