Kubernetes pod/deploy/sts/ds example
September 12, 2022
Pod Ubuntu
Установим pod с пустой Ubuntu:latest
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: cam-ubuntu
namespace: default
labels:
environment: test
app: ubuntu
annotations:
author: cameda
spec:
containers:
- name: ubuntu
image: ubuntu:latest
command: ["/bin/sleep", "3650d"]
imagePullPolicy: IfNotPresent
restartPolicy: Always
EOFkubectl get pods -A -l environment=test NAMESPACE NAME READY STATUS RESTARTS AGE default cam-ubuntu 1/1 Running 0 48s
kubectl describe po cam-ubuntu
Error from server (NotFound): pods "am-ubuntu" not found
cameda-osx:~ cameda$ kubectl describe po cam-ubuntu
Name: cam-ubuntu
Namespace: default
Priority: 0
Node: cl1r12kvg8q3mf91ohla-usen/10.128.0.29
Start Time: Mon, 12 Sep 2022 12:52:38 +0300
Labels: app=ubuntu
environment=test
Annotations: cni.projectcalico.org/podIP: 10.96.128.10/32
kubernetes.io/limit-ranger: LimitRanger plugin set: cpu, memory request for container ubuntu; cpu, memory limit for container ubuntu
Status: Running
IP: 10.96.128.10
IPs:
IP: 10.96.128.10
Containers:
ubuntu:
Container ID: containerd://f828c4feafc4af60ea82ca4703ab911d27f0ccdb86b24b2f9cb99555be75a2ad
Image: ubuntu:latest
Image ID: docker.io/library/ubuntu@sha256:20fa2d7bb4de7723f542be5923b06c4d704370f0390e4ae9e1c833c8785644c1
Port: <none>
Host Port: <none>
Command:
/bin/sleep
3650d
State: Running
Started: Mon, 12 Sep 2022 12:52:39 +0300
Ready: True
Restart Count: 0
Limits:
cpu: 500m
memory: 500Mi
Requests:
cpu: 500m
memory: 500Mi
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-rwkg6 (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-rwkg6:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: Guaranteed
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 2m6s default-scheduler Successfully assigned default/cam-ubuntu to cl1r12kvg8q3mf91ohla-usen
Normal Pulled 2m5s kubelet Container image "ubuntu:latest" already present on machine
Normal Created 2m5s kubelet Created container ubuntu
Normal Started 2m5s kubelet Started container ubuntukubectl exec --stdin --tty cam-ubuntu -- /bin/bash
Посмотрим логи пода и потребляемые ресурсы:
kubectl top pod cam-ubuntu --containers kubectl logs cam-ubuntu
Установка программ и просмотр информации:
apt-get -y update apt-get -y install dnsutils apt-get -y install iputils-ping apt -y install htop mc traceroute strace apt-get -y install postgresql uname -a hostname
ping ya.ru PING ya.ru (87.250.250.242) 56(84) bytes of data. 64 bytes from ya.ru (87.250.250.242): icmp_seq=1 ttl=57 time=0.623 ms
dig ya.ru ; <<>> DiG 9.18.1-1ubuntu1.1-Ubuntu <<>> ya.ru ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20704 ;; flags: qr ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1232 ; COOKIE: 4d3e68213979872b (echoed) ;; QUESTION SECTION: ;ya.ru. IN A ;; ANSWER SECTION: ya.ru. 30 IN A 87.250.250.242 ;; AUTHORITY SECTION: ya.ru. 30 IN NS ns2.yandex.ru. ya.ru. 30 IN NS ns1.yandex.ru. ;; Query time: 4 msec ;; SERVER: 10.112.128.2#53(10.112.128.2) (UDP) ;; WHEN: Mon Sep 12 10:15:46 UTC 2022 ;; MSG SIZE rcvd: 131
September 12, 2022, 10:16
0 views
0 reposts