Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 정규식 활용
- c3 second
- g++ 업데이트
- 정규식 컴파일
- snmp test
- c3 step graph
- semanage
- selinux port 등록
- influxdb 설치
- c3 축 가리기
- InfluxDB
- telegraf
- 백준
- snmp
- CentOS7
- python popen
- c++ 정규식
- 정규식 문자열 출력
- grafana dashboard
- gcc 업데이트
- c3 초
- python os
- linux시간으로 변경
- gcc regex
- centos pyhon 설치
- subporcess path
- 1697
- c3 축 없애기
- python subprocess
- regex_search
Archives
- Today
- Total
리셋 되지 말자
[k8s] Pod 생성시간 계산하기 - Python 본문
now = datetime.datetime.now().replace(microsecond = 0)
api server에 요청하여 Pod 정보 획득
kubectl을 이용해서 해당 Pod의 생성 시간을 획득할 수 있다. (Z는 utc timezon을 의미한다고 한다)
kubectl get pod <pod 이름> -o json | jq -r ".metadata.creationTimestamp"
2023-01-27T08:20:42Z
Python을 이용해 생성 시간 변환 - 초(second)
datetime 모듈을 이용해 Pod가 몇초전에 생성되었는지 구한다. microsecond는 0으로 치환하지 않아도 되지만, 옵션으로 추가했다.
import datetime
string="2023-01-27T08:20:42Z"
pod_create_time = datetime.datetime.strptime(string, "%Y-%m-%dT%H:%M:%SZ")
>>> pod_create_time
datetime.datetime(2023, 1, 27, 8, 20, 42)
now_time = datetime.datetime.now().replace(microsecond=0)
>>> now_time
datetime.datetime(2023, 1, 30, 18, 40, 33)
(now_time - pod_create_time).seconds
37191
'오케스트레이션' 카테고리의 다른 글
[k8s] nginx service, deployment 예제 (0) | 2022.12.14 |
---|---|
[k8s] eks 클러스터에 IAM 사용자 추가(Role, RoleBinding 등) (0) | 2022.09.21 |
[k8s] Istio mTLS 완전정복 (0) | 2022.07.22 |
[kubernetes] Pod 생성 (0) | 2021.07.15 |
[kubernetes] kube-proxy (0) | 2021.07.14 |
Comments