Skip to content

Faketime for your applicationΒΆ

How to inject https://github.com/wolfcw/libfaketime into your application deployment or you use the Time Machine Operator

 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
kind: Deployment
apiVersion: apps/v1
metadata:
  name: libfaketime
  labels:
    app: libfaketime
    app.kubernetes.io/component: libfaketime
    app.kubernetes.io/instance: libfaketime
    app.kubernetes.io/name: libfaketime
    app.kubernetes.io/part-of: libfaketime-app
    app.openshift.io/runtime: other-linux
spec:
  replicas: 1
  selector:
    matchLabels:
      app: libfaketime
  template:
    metadata:
      labels:
        app: libfaketime
    spec:
      volumes:
      - name: libfaketime
        emptyDir: {}
      initContainers:
        - name: build-libfaketime
          image: registry.redhat.io/rhel8/gcc-toolset-11-toolchain:11-6
          env:
            - name: VERSION
              value: 0.9.9
          volumeMounts:
            - mountPath: /libfaketime/
              name: libfaketime
          command:
            - /bin/sh
            - -c
            - |
              set -x
              cd /tmp/
              curl -# -L -O https://github.com/wolfcw/libfaketime/archive/refs/tags/v${VERSION}.tar.gz
              tar xzvf v${VERSION}.tar.gz
              cd libfaketime-${VERSION}/
              PREFIX=/libfaketime/ make install
      containers:
        - name: date
          image: registry.access.redhat.com/ubi8/ubi-micro
          env:
            - name: LD_PRELOAD
              value: /libfaketime/lib/faketime/libfaketime.so.1
            - name: FAKETIME
              value: "-365d"
          command:
            - /bin/sh
            - '-c'
            - |
              while true; do
                date
                sleep 1
              done;
          volumeMounts:
            - mountPath: /libfaketime/
              name: libfaketime
          imagePullPolicy: Always
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      securityContext: {}
      schedulerName: default-scheduler
  strategy:
    type: Recreate
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600
1
oc apply -f https://examples.openshift.pub/deploy/faketime/content/deploy/libfaketime.yaml

Last update: February 11, 2022