-
get image full registry name by running:
docker pull redis
-
Result
Using default tag: latest latest: Pulling from library/redis Digest: sha256:a89cb097693dd354de598d279c304a1c73ee550fbfff6d9ee515568e0c749cfe Status: Image is up to date for redis:latest docker.io/library/redis:latest
🔔 In result above image
redis
's full name is reallydocker.io/library/redis:latest
(docker.io
- docker maintained registry,library
officially maintained by docker team,latest
becuse we didn't specify is default version)🔔 the
latest
tag's digest sha ->sha256:a89cb097693dd354de598d279c304a1c73ee550fbfff6d9ee515568e0c749cfe
🔔 So the exact version of the image is
docker.io/library/redis:latest:sha256@a89cb097693dd354de598d279c304a1c73ee550fbfff6d9ee515568e0c749cfe
- Create deployment for redis:
- image name:
docker.io/library/redis:
- image version:
latest:sha256@a89cb097693dd354de598d279c304a1c73ee550fbfff6d9ee515568e0c749cfe
- image name:
# 🔔 note: --dry-run=client -oyaml > ./deployment/kustomize/manifests/redis/deployment.yaml for reuse
kubectl create deployment --image=docker.io/library/redis:latest@sha256:a89cb097693dd354de598d279c304a1c73ee550fbfff6d9ee515568e0c749cfe redis --port=6379 --dry-run=client -oyaml > ./deployment/kustomize/manifests/redis/deployment.yaml
📓 -> Any yaml file including kubernes configuration, in our example, a deployment
object,
can be done via kubectl apply -f /path/to/file [ -f another-file ] ...
kubectl apply -f ./deployment/kustomize/manifests/redis/deployment.yaml
📓 the pod id presented below, may differ in your setup ...
kubectl get po
NAME READY STATUS RESTARTS AGE
redis-7dcd746c6-sj9w8 1/1 Running 0 88m
The following command will help make this command more user-freindly using the label/selector of the deployment:
kubectl get po -l app=redis
- This is equivalent in docker -> docker run
without -p
(sevice not accessibel via host) ... and we mustdocker attach <contaoerId>
kubectl port-forward redis-7dcd746c6-sj9w8 6379:6379
For a service to be able to access another service in the cluster, we need a service of type ClusterIP
which is the default kuberentes service type (more on the other later ...), once you have a service name foo
pointing to a deployment
by using tags + selctors:
e.g.
# from ./deployment/kustomize/manifests/redis/deployment.yaml
...
spec:
replicas: 1
selector:
matchLabels:
app: redis
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: redis
...
Using kubectl expose deployment
kubectl expose deployment redis --port=6379 --dry-run=client -oyaml > ./deployment/kustomize/manifests/redis/svc.yaml
kubectl apply -f ./deployment/kustomize/manifests/redis/svc.yaml
kubectl port-forward svc/redis 6379:6379
kubectl exec -it `kubectl get pod -l app=redis | grep redis| awk '{print $1}'` -- redis-cli GET pings
should yield:
""
After we deploy pinger we will run this again ...
🆙 next deploy - microservices