Created
January 18, 2020 00:32
-
-
Save JohnKDay/3318b27b45be4f9f7be4bcc8fce7965b to your computer and use it in GitHub Desktop.
Compare date and time of all nodes from a Kubernetes container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: apps/v1beta2 | |
kind: DaemonSet | |
metadata: | |
name: datetimecheck | |
spec: | |
selector: | |
matchLabels: | |
name: datetimecheck | |
template: | |
metadata: | |
labels: | |
name: datetimecheck | |
spec: | |
initContainers: | |
- name: datechecker | |
image: busybox | |
command: ["sh"] | |
args: ["-c", "hostname; echo \" Website\" $(wget https://google.com -qS 2>&1 | grep -i date | head -1); date -u +\"Container Date: %a, %d %b %Y %T %Z\"; echo"] | |
containers: | |
- name: pause | |
image: gcr.io/google_containers/pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple yaml file for k8s to create a Daemonset that will run on all of the nodes and check between internet time and local container time derived from k8s node.
kubectl apply -f datecheck.yaml
or
(above script in raw mode)
after a bit check the logs
kubectl logs -l name=datetimecheck --all-containers
Response should look like:
And don't forget to delete the Daemonset when finished
kubectl delete daemonsets datetimecheck
or delete pods to rerun
kubectl delete pods -l name=datetimecheck