-
Notifications
You must be signed in to change notification settings - Fork 2
/
c2s-instance-metadata-machineconfig.yaml
42 lines (37 loc) · 1.45 KB
/
c2s-instance-metadata-machineconfig.yaml
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
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: {{MASTER_OR_WORKER}}
name: c2s-instance-metadata-{{MASTER_OR_WORKER}}
spec:
config:
ignition:
version: 3.1.0
systemd:
units:
- name: c2s-instance-metadata-setup.service
enabled: true
contents: |
[Unit]
Description=Setup for C2S Instance Metadata Emulator
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/bin/sh -c 'if ! id metadata &>/dev/null; then useradd -p "*" -U -m metadata -G sudo; fi; mkdir -p /var/home/metadata/.docker; cp /var/lib/kubelet/config.json /var/home/metadata/.docker/; chown -R metadata:metadata /var/home/metadata/.docker'
ExecStart=iptables -t nat -I OUTPUT -p tcp -m owner ! --uid-owner metadata --dst 169.254.169.254 --dport 80 -j REDIRECT --to-ports 4000
[Install]
WantedBy=multi-user.target
- name: c2s-instance-metadata.service
enabled: true
contents: |
[Unit]
Description=C2S Instance Metadata Emulator
Wants=c2s-instance-metadata-setup.service
After=c2s-instance-metadata-setup.service
[Service]
User=metadata
ExecStart=podman run --userns keep-id --net host {{C2S-INSTANCE-METADATA-IMAGE}}
Restart=always
[Install]
WantedBy=multi-user.target