k8s cheatsheet

k get all –all-namespaces

k -n kube-system get configmap calico-config
k -n kube-system get configmap calico-config -o yaml

kubectl get clusterrolebindings system:node –all-namespaces -o json

k8s sandbox

FAILED!!!
I can access the 5 pods but not the serice

https://kubernetes.io/docs/tutorials/stateless-application/expose-external-ip-address/

kubectl expose deployment hello-world –type=NodePort –name=example-service

I wanted to force a nodeport
I wish I could figure out a yaml for this but ended up with this becaue the yaml always said endpoints:none

so I used:
kubectl expose deployment hello-world –type=NodePort –name=example-service –overrides ‘{ “apiVersion”: “v1″,”spec”:{“ports”:[{“port”:8080,”protocol”:”TCP”,”targetPort”:8080,”nodePort”:30031}]}}’

works:
curl http://10.110.245.152:8080

but on a0 does not work:
curl http://10.110.245.152:8080

k describe deployment hello-world
Name: hello-world
Namespace: default
CreationTimestamp: Wed, 28 Oct 2020 03:05:08 -0400
Labels: app.kubernetes.io/name=load-balancer-example
Annotations: deployment.kubernetes.io/revision: 1
Selector: app.kubernetes.io/name=load-balancer-example
Replicas: 5 desired | 5 updated | 5 total | 5 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app.kubernetes.io/name=load-balancer-example
Containers:
hello-world:
Image: gcr.io/google-samples/node-hello:1.0
Port: 8080/TCP
Host Port: 0/TCP
Environment:
Mounts:
Volumes:
Conditions:
Type Status Reason
—- —— ——
Progressing True NewReplicaSetAvailable
Available True MinimumReplicasAvailable
OldReplicaSets:
NewReplicaSet: hello-world-6df5659cb7 (5/5 replicas created)
Events:

kubectl expose deployment hello-world –type=NodePort –name=example-service

phomlish@k0:~$ kubectl describe services example-service
Name: example-service
Namespace: default
Labels: app.kubernetes.io/name=load-balancer-example
Annotations:
Selector: app.kubernetes.io/name=load-balancer-example
Type: NodePort
IP: 10.110.245.152
Port: 8080/TCP
TargetPort: 8080/TCP
NodePort: 30140/TCP
Endpoints: 10.166.32.215:8080,10.166.32.222:8080,10.166.32.233:8080 + 2 more…
Session Affinity: None
External Traffic Policy: Cluster
Events:

k get endpoints example-service -o yaml
apiVersion: v1
kind: Endpoints
metadata:
annotations:
endpoints.kubernetes.io/last-change-trigger-time: “2020-11-01T09:23:22Z”
creationTimestamp: “2020-11-01T09:23:22Z”
labels:
app.kubernetes.io/name: load-balancer-example
managedFields:
– apiVersion: v1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.: {}
f:endpoints.kubernetes.io/last-change-trigger-time: {}
f:labels:
.: {}
f:app.kubernetes.io/name: {}
f:subsets: {}
manager: kube-controller-manager
operation: Update
time: “2020-11-01T09:23:22Z”
name: example-service
namespace: default
resourceVersion: “1485713”
selfLink: /api/v1/namespaces/default/endpoints/example-service
uid: 27c316f9-57d6-413b-93ca-20458d875925
subsets:
– addresses:
– ip: 10.166.32.215
nodeName: k0
targetRef:
kind: Pod
name: hello-world-6df5659cb7-fjqrc
namespace: default
resourceVersion: “1472538”
uid: e870d96c-07a4-435f-a57c-88307b3dda3f
– ip: 10.166.32.222
nodeName: k0
targetRef:
kind: Pod
name: hello-world-6df5659cb7-n9klg
namespace: default
resourceVersion: “1472588”
uid: c2965c4c-c679-4519-8f5e-f4cca25b1942
– ip: 10.166.32.233
nodeName: k0
targetRef:
kind: Pod
name: hello-world-6df5659cb7-5x6wb
namespace: default
resourceVersion: “1472473”
uid: ff188c54-dab9-4d27-a301-06ea256c0588
– ip: 10.166.32.236
nodeName: k0
targetRef:
kind: Pod
name: hello-world-6df5659cb7-9x9lx
namespace: default
resourceVersion: “1472726”
uid: 55a09551-9136-4e23-aa14-c18fbada63f4
– ip: 10.166.32.242
nodeName: k0
targetRef:
kind: Pod
name: hello-world-6df5659cb7-9fdzx
namespace: default
resourceVersion: “1472578”
uid: abd01d7a-be6b-4aaa-900e-d8d2f54a1831
ports:
– port: 8080
protocol: TCP

Name: example-service
Namespace: default
Labels: name=load-balancer-example
Annotations:
Selector: app=load-balancer-example
Type: NodePort
IP: 10.97.241.235
Port: ihttpd 8080/TCP
TargetPort: 8080/TCP
NodePort: ihttpd 30163/TCP
Endpoints:
Session Affinity: None
External Traffic Policy: Cluster
Events:

from a0
curl http://10.11.1.70:30140