Skip to content

Instantly share code, notes, and snippets.

@thikade
Last active April 24, 2024 10:03
Show Gist options
  • Save thikade/9210874f322e72fb9d7096851d509e35 to your computer and use it in GitHub Desktop.
Save thikade/9210874f322e72fb9d7096851d509e35 to your computer and use it in GitHub Desktop.
Redhat Openshift Agent-based Installer files for SNO & compact-cluster
# use same agent-config.yaml from compact-cluster.yaml!
---
# >>>>>> A 3-node, _compact_ cluster: <<<<<<<<<<<<
## API-VIP and APPS-VIP will be taken care of via keepalived,
## and you just need to provide API IPs and DNS records!
# 192.168.50.2 api.demo.cloud.example.com
# 192.168.50.2 api-int.demo.cloud.example.com
# 192.168.50.3 *.apps.demo.cloud.example.com
##
# install-config.yaml
##
apiVersion: v1
metadata:
name: demo
baseDomain: cloud.a-it.dev
compute:
- architecture: amd64
hyperthreading: Enabled
name: worker
replicas: 0
controlPlane:
architecture: amd64
hyperthreading: Enabled
name: master
replicas: 3
networking:
clusterNetwork:
- cidr: 10.128.0.0/14
hostPrefix: 23
machineNetwork:
- cidr: 192.168.50.0/24
networkType: OVNKubernetes
serviceNetwork:
- 172.30.0.0/16
platform:
baremetal:
apiVIPs:
- 192.168.50.2
ingressVIPs:
- 192.168.50.3
sshKey: "ssh-xxxx"
pullSecret: '{"auths":{"registry.demo.cloud.a-it.dev:5000":{"auth":"xxx","email":"me"},"cloud.openshift.com":......'
imageContentSources:
- mirrors:
- registry.demo.cloud.a-it.dev:5000/ocp4/openshift4
source: quay.io/openshift-release-dev/ocp-release
- mirrors:
- registry.demo.cloud.a-it.dev:5000/ocp4/openshift4
source: quay.io/openshift-release-dev/ocp-v4.0-art-dev
additionalTrustBundle: |
-----BEGIN CERTIFICATE-----
MIIDgzCCAmugAwIBAgITUXD/T5N1BOE6q3F7HLTI7gqR6TANBgkqhkiG9w0BAQsF
....
vaTcG9uIXa9d/6b+b47U6GSG0CGVd7Rerg5qjM9FvFgGTxEKvZtm
-----END CERTIFICATE-----
---
# >>>>>> A 3-node, _compact_ cluster: <<<<<<<<<<<<
## API-VIP and APPS-VIP will be taken care of via keepalived,
## and you just need to provide API IPs and DNS records!
# 192.168.50.2 api.demo.cloud.example.com
# 192.168.50.2 api-int.demo.cloud.example.com
# 192.168.50.3 *.apps.demo.cloud.example.com
##
# install-config.yaml
##
install-config.yaml_COMPACT
apiVersion: v1
metadata:
name: demo
baseDomain: cloud.example.com
compute:
- architecture: amd64
hyperthreading: Enabled
name: worker
replicas: 0
controlPlane:
architecture: amd64
hyperthreading: Enabled
name: master
replicas: 3
networking:
clusterNetwork:
- cidr: 10.128.0.0/14
hostPrefix: 23
machineNetwork:
- cidr: 192.168.50.0/24
networkType: OVNKubernetes
serviceNetwork:
- 172.30.0.0/16
platform:
baremetal:
apiVIPs:
- 192.168.50.2
ingressVIPs:
- 192.168.50.3
sshKey: "ssh-..."
pullSecret: '{"auths":{"cloud....'
---
#
# agent-config.yaml needs to define 3 clusters
#
apiVersion: v1beta1
kind: AgentConfig
metadata:
name: demo
rendezvousIP: 192.168.50.10
hosts:
- hostname: master0
interfaces:
- name: eno1
macAddress: 52:54:00:9b:79:2b
rootDeviceHints:
deviceName: /dev/vda
networkConfig:
interfaces:
- name: eno1
type: ethernet
state: up
mac-address: 52:54:00:9b:79:2b
ipv4:
enabled: true
address:
- ip: 192.168.50.10
prefix-length: 24
dhcp: false
dns-resolver:
config:
server:
- 192.168.50.1
routes:
config:
- destination: 0.0.0.0/0
next-hop-address: 192.168.50.1
next-hop-interface: eno1
table-id: 254
- hostname: master1
interfaces:
- name: eno1
macAddress: 52:54:00:b1:90:c1
rootDeviceHints:
deviceName: /dev/vda
networkConfig:
interfaces:
- name: eno1
type: ethernet
state: up
mac-address: 52:54:00:b1:90:c1
ipv4:
enabled: true
address:
- ip: 192.168.50.11
prefix-length: 24
dhcp: false
dns-resolver:
config:
server:
- 192.168.50.1
routes:
config:
- destination: 0.0.0.0/0
next-hop-address: 192.168.50.1
next-hop-interface: eno1
table-id: 254
- hostname: master2
interfaces:
- name: eno1
macAddress: 52:54:00:a3:45:4f
rootDeviceHints:
deviceName: /dev/vda
networkConfig:
interfaces:
- name: eno1
type: ethernet
state: up
mac-address: 52:54:00:a3:45:4f
ipv4:
enabled: true
address:
- ip: 192.168.50.12
prefix-length: 24
dhcp: false
dns-resolver:
config:
server:
- 192.168.50.1
routes:
config:
- destination: 0.0.0.0/0
next-hop-address: 192.168.50.1
next-hop-interface: eno1
table-id: 254
## see https://github.com/RedHat-EMEA-SSA-Team/openshift-4-loadbalancer
cat <<EOT > /etc/sysconfig/openshift-lb.env
HAPROXY_CFG="global
log 127.0.0.1 local2
pidfile /var/run/haproxy.pid
maxconn 4000
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
defaults
mode http
log global
option dontlognull
option http-server-close
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
listen ingress-http
bind 192.168.50.1:80
bind 49.12.148.71:80
mode tcp
server master-0 192.168.50.10:80 check inter 1s
server master-1 192.168.50.11:80 check inter 1s
server master-2 192.168.50.12:80 check inter 1s
server compute-0 192.168.50.13:80 check inter 1s
server compute-1 192.168.50.14:80 check inter 1s
server compute-2 192.168.50.15:80 check inter 1s
listen ingress-https
bind 192.168.50.1:443
bind 49.12.148.71:443
mode tcp
server master-0 192.168.50.10:443 check inter 1s
server master-1 192.168.50.11:443 check inter 1s
server master-2 192.168.50.12:443 check inter 1s
server compute-0 192.168.50.13:443 check inter 1s
server compute-1 192.168.50.14:443 check inter 1s
server compute-2 192.168.50.15:443 check inter 1s
listen api
bind 192.168.50.1:6443
bind 49.12.148.71:6443
mode tcp
server bootstrap 192.168.50.2:6443 check inter 1s backup
server master-0 192.168.50.10:6443 check inter 1s
server master-1 192.168.50.11:6443 check inter 1s
server master-2 192.168.50.12:6443 check inter 1s
server compute-0 192.168.50.13:6443 check inter 1s
server compute-1 192.168.50.14:6443 check inter 1s
server compute-2 192.168.50.15:6443 check inter 1s
listen machine-config-server
bind 192.168.50.1:22623
bind 49.12.148.71:22623
mode tcp
server bootstrap 192.168.50.2:22623 check inter 1s backup
server master-0 192.168.50.10:22623 check inter 1s
server master-1 192.168.50.11:22623 check inter 1s
server master-2 192.168.50.12:22623 check inter 1s
listen machine-config-server2
bind 192.168.50.1:22624
bind 49.12.148.71:22624
mode tcp
server bootstrap 192.168.50.2:22624 check inter 1s backup
server master-0 192.168.50.10:22624 check inter 1s
server master-1 192.168.50.11:22624 check inter 1s
server master-2 192.168.50.12:22624 check inter 1s
"
EOT
# ------------------------------------------------------------
cat <<EOT > openshift-lb.service
[Unit]
Description=OpenShift 4 LoadBalancer
After=network.target
[Service]
Type=simple
TimeoutStartSec=5m
EnvironmentFile=/etc/sysconfig/openshift-lb.env
ExecStartPre=-/usr/bin/podman rm "openshift-lb"
ExecStartPre=/usr/bin/podman pull quay.io/redhat-emea-ssa-team/openshift-4-loadbalancer:master
ExecStart=/usr/bin/podman run --name openshift-lb --net host --env-host=true \
quay.io/redhat-emea-ssa-team/openshift-4-loadbalancer:master
ExecReload=-/usr/bin/podman stop "openshift-lb"
ExecReload=-/usr/bin/podman rm "openshift-lb"
ExecStop=-/usr/bin/podman stop "openshift-lb"
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
EOT
# https://docs.openshift.com/container-platform/4.14/installing/installing_bare_metal/installing-restricted-networks-bare-metal.html#installation-configure-proxy_installing-restricted-networks-bare-metal
apiVersion: v1
baseDomain: <domain>
proxy:
httpProxy: http://<username>:<pswd>@<ip>:<port>
httpsProxy: https://<username>:<pswd>@<ip>:<port>
noProxy: .example.com,10.1.2.0/16
# ./openshift-install --dir CLUSTER-demo agent wait-for install-complete
...
INFO Host: master0, reached installation stage Writing image to disk: 70%
INFO Host: master0, reached installation stage Writing image to disk: 76%
INFO Host: master1, reached installation stage Writing image to disk: 95%
INFO Host: master0, reached installation stage Writing image to disk: 93%
INFO Host: master0, reached installation stage Waiting for control plane: Waiting for masters to join bootstrap control plane
INFO Bootstrap Kube API Initialized
INFO Host: master1, reached installation stage Configuring
INFO Host: master0, reached installation stage Waiting for bootkube
INFO Host: master2, reached installation stage Done
INFO Node master1 has been rebooted 2 times before completing installation
INFO Bootstrap configMap status is complete
INFO cluster bootstrap is complete
<WAIT> some more minutes!
INFO Cluster is installed
INFO Install complete!
INFO To access the cluster as the system:admin user when using 'oc', run
INFO export KUBECONFIG=/root/agent-based-installer/CLUSTER-demo/auth/kubeconfig
INFO Access the OpenShift web-console here: https://console-openshift-console.apps.demo.cloud.example.com
INFO Login to the console with user: "kubeadmin", and password: "xxxxx-xxxxx-xxxxx-xxxxx"
# NOTE: API and APPS VIPs will default to the SNO IP!
#### you just need to provide API IPs and DNS records:
# 192.168.50.10 api.demo.cloud.example.com
# 192.168.50.10 api-int.demo.cloud.example.com
# 192.168.50.10 *.apps.demo.cloud.example.com
---
#
# install-config.yaml
#
apiVersion: v1
metadata:
name: demo
baseDomain: cloud.example.com
compute:
- architecture: amd64
hyperthreading: Enabled
name: worker
replicas: 0
controlPlane:
architecture: amd64
hyperthreading: Enabled
name: master
replicas: 1
networking:
clusterNetwork:
- cidr: 10.128.0.0/14
hostPrefix: 23
machineNetwork:
- cidr: 192.168.50.0/24
networkType: OVNKubernetes
serviceNetwork:
- 172.30.0.0/16
platform:
none: {}
sshKey: "ssh-...."
pullSecret: '{"auths":{...'
---
#
# agent-config.yaml
#
agent-config.yaml
apiVersion: v1beta1
kind: AgentConfig
metadata:
name: demo
rendezvousIP: 192.168.50.10
hosts:
- hostname: master
interfaces:
- name: eno1
macAddress: 52:54:00:9b:79:2b
rootDeviceHints:
deviceName: /dev/vda
networkConfig:
interfaces:
- name: eno1
type: ethernet
state: up
mac-address: 52:54:00:9b:79:2b
ipv4:
enabled: true
address:
- ip: 192.168.50.10
prefix-length: 24
dhcp: false
dns-resolver:
config:
server:
- 192.168.50.1
routes:
config:
- destination: 0.0.0.0/0
next-hop-address: 192.168.50.1
next-hop-interface: eno1
table-id: 254
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment