k8s persistent volume

k patch pv imagesdev -p ‘{“spec”:{“claimRef”: null}}’

k0:/home/phomlish/kubernetes/test-pv
k config set-context –current –namespace=kube-public

k apply -f test-image.yaml
k get pod shell-demo
k exec –stdin –tty shell-demo — /bin/bash
k exec shell-demo env

k delete -f shell-demo.yaml

k get pod shell-demo -o wide

k patch pv homlishca -p ‘{“spec”:{“claimRef”: null}}’

jenkins

https://www.jenkins.io/doc/book/installing/docker/

docker network create jenkins
docker network create jenkins.homlish.net

docker run \
–name jenkins-docker \
–rm \
–detach \
–privileged \
–network jenkins \
–network-alias docker \
–env DOCKER_TLS_CERTDIR=/certs \
–volume jenkins-docker-certs:/certs/client \
–volume jenkins-data:/var/jenkins_home \
–publish 2376:2376 \
docker:dind

docker run \
–name jenkins-docker \
–detach \
–privileged \
–network jenkins \
–network-alias docker \
–env DOCKER_TLS_CERTDIR=/certs \
–volume jenkins-docker-certs:/certs/client \
–volume jenkins-data:/var/jenkins_home \
–publish 2376:2376 \
docker:dind

docker stop jenkins-docker

Continue reading “jenkins”

k8s registry

https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/

let’s create a secret to access hcr.homlish.net

login using the k8s user
docker login hcr.homlish.net:8443

k create secret generic regcred -n default \
–from-file=.dockerconfigjson=/home/phomlish/.docker/config.json \
–type=kubernetes.io/dockerconfigjson

we need to copy that to whatever namespace need it
k delete secret –namespace=homlish-web-dev regcred
k get secret regcred –namespace=default -oyaml| grep -v ‘^\s*namespace:\s’ | k apply –namespace=homlish-web-dev -f –

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

docker registry

https://docs.docker.com/registry/deploying/

htpasswd:
on a0:
/usr/local/apache2/bin/htpasswd -Bbn username **** > htpasswd
on k0:
edit /home/phomlish/hcr/auth/htpasswd
docker restart hcr
docker login hcr.homlish.net:8443

docker images 10.11.1.70:5000/my-ubuntu -a

docker container stop registry

next up: move it to kubernetes

echo login
docker login hcr.homlish.net:8443

echo “set version $(cat VERSION)”
VERSION=$(cat VERSION)
echo ${VERSION}

echo build
docker build -f /Users/phomlish/go/src/homlish-web-go/Dockerfile -t hw/hw:${VERSION} .
docker run -i -t hw/hw:${VERSION} bash

echo “tag and push”
docker tag hw/hw:${VERSION} hcr.homlish.net:8443/hw/hw:${VERSION}
docker push hcr.homlish.net:8443/hw/hw:${VERSION}

docker tag hw/hw:${VERSION} hw/hw:latest
docker tag hw/hw:latest hcr.homlish.net:8443/hw/hw:latest
docker push hcr.homlish.net:8443/hw/hw:latest

docker images hcr.homlish.net:8443/hw/hw