OCP4 Tips P.07/Install OpenShift on VMware Using IPI Method and static IPs.

OCP4 Tips P.07/Install OpenShift on VMware Using IPI Method and static IPs.

Hello All,

Today we are going to talk about new feature on OpenShift 4.14 enable us to install OpenShift on VMware using IPI Method and static IPs not DHCP.

to understand this article, you should have the knowledge on IPI installation method as I'm not going to dig deep on how it work or what are the alternatives to.

put in a nutshell. IPI is a fully automated way to install Openshift on many platforms which means it is responsible for creating the infrastructure and all requirements for OpenShift to be up and running.

here are the things that IPI build by itself on VMware:

  • OCP nodes
  • Create and attaches disks to the nodes.
  • attaches the nodes to network.

and now it can also do the following:

  • give node static IPs and gateway.
  • give node the dns configuration.

before that we used to must have DHCP to give the created node the IPs, gateway and DNS in installation and scale out the cluster.

Steps

  • create linux/bastion machine
  • on the bastion machine generate ssh key

ssh-keygen -t ecdsa
cat /root/.ssh/id_ecdsa.pub        

  • wget vcenter certs and make bastion machine trust them

wget https://<vcenter-ip>/certs/download.zip --no-check-certificate
unzip download.zip
mv certs/lin/* /etc/pki/ca-trust/source/anchors/
update-ca-trust
update-crypto-policies --set DEFAULT        

  • create user on VMware with mentioned Privileges
  • create install-config.yaml file and copy/save it befor run installer as it will destroy it.

apiVersion: v1
baseDomain: <example.com>
# proxy section is optional use it only if you are connected to internet using proxy 
proxy:
  httpProxy: https://<ip>:<port>
  httpsProxy: https://<ip>:<port>
  noProxy: <.example.com>
# this section is also optional , use it to add any crt you need your oprnshift to trust , for example your proxy crt
additionalTrustBundle: |
     -----BEGIN CERTIFICATE-----
     <your-crt>
     -----END CERTIFICATE-----
compute:
- architecture: amd64
  hyperthreading: Enabled
  name: worker
  platform:
    vsphere:
      cpus: 8
      coresPerSocket: 4
      memoryMB: 16384
      osDisk:
        diskSizeGB: 150
  replicas: 3
controlPlane:
  architecture: amd64
  hyperthreading: Enabled
  name: master
  platform:
    vsphere:
      cpus: 8
      coresPerSocket: 4
      memoryMB: 16384
      osDisk:
        diskSizeGB: 150
  replicas: 3
platform:
  vsphere:
    cluster: <cluster-name>
    datacenter: <datacenter-name>
# you can't use datastore which part of datastorage cluster, you can only use normal datastore
    defaultDatastore:  <datastore-name>
    folder: <folder-path>
# if network name contain / replace it with %2f
    network: <network-name>
    password: <password>
    username: <username>
    vCenter: <vcenter-ip>
    apiVIPs:
      - <api-vip>
    ingressVIPs:
      - <ingress-vip>
    hosts:
    - role: bootstrap
      networkDevice:
        ipAddrs:
        - <ip>
        gateway: <gw>
        nameservers:
        - <dns1>
        - <dns2>
    - role: control-plane
      networkDevice:
        ipAddrs:
        - <ip>
        gateway: <gw>
        nameservers:
        - <dns1>
        - <dns2>
    - role: control-plane
      networkDevice:
      ipAddrs:
        - <ip>
        gateway: <gw>
        nameservers:
        - <dns1>
        - <dns2>
    - role: control-plane
      networkDevice:
        ipAddrs:
        - <ip>
        gateway: <gw>
        nameservers:
        - <dns1>
        - <dns2>
    - role: compute
      networkDevice:
        ipAddrs:
        ipAddrs:
        - <ip>
        gateway: <gw>
        nameservers:
        - <dns1>
        - <dns2>
    - role: compute
      networkDevice:
        ipAddrs:
        - <ip>
        gateway: <gw>
        nameservers:
        - <dns1>
        - <dns2>   
    - role: compute
      networkDevice:
        ipAddrs:
        - <ip>
        gateway: <gw>
        nameservers:
        - <dns1>
        - <dns2>
metadata:
  creationTimestamp: null
  name: <cluster-name>
networking:
  clusterNetwork:
  - cidr: 10.128.0.0/14
    hostPrefix: 23
  machineNetwork:
  - cidr: <node-subnet>
  networkType: OpenShiftSDN
  serviceNetwork:
  - 172.30.0.0/16
publish: External
fips: true
# you must enable this to use the static IP feature as it is not ready for production yet
# also not that enable it in testing cluster as it will block cluster upgrade between minor versions
# so upgrade 4.14 to 4.15 will be blocked
featureSet: TechPreviewNoUpgrade
pullSecret: <pull-secret>
sshKey: <ssh-key>
        

  • run installer

openshift-install create cluster --dir=./<install-config-dir>/ --log-level=debug
```        

  • wait bootstrap to complete

ssh core@bootsrap-ip

systemctl list-units --type=service
systemctl status bootkube
journalctl -u bootkube
journalctl -u -f bootkube
journalctl -u bootkube -f
#once completed exit and run 

openshift-install wait-for bootstrap-complete --dir=./<install-config-dir>/ --log-level=debug        

  • wait installation to complete

export KUBECONFIG=/root/ocp-acm/install-assets/auth/kubeconfig
oc completion bash >> /etc/bash_completion.d/oc_completion

openshift-install wait-for install-complete --dir=./<install-config-dir>/ --log-level=debug        

now you have cluster provisioned on VMware using IPI and static IPs not DHCP.

let's create more nodes now.

Steps

  • get cluster id

oc get machines.machine.openshift.io -n openshift-machine-api
NAME                 PHASE     TYPE   REGION   ZONE   AGE
ocp-ygtrf-master-0   Running                          28d
ocp-ygtrf-master-1   Running                          28d
ocp-ygtrf-master-2   Running                          28d
ocp-ygtrf-worker-0   Running                          28d
ocp-ygtrf-worker-1   Running                          28d
ocp-ygtrf-worker-2   Running                          28d

# cluster if form is <cluster-name>.<random-charachters>
# in our case it is ocp-ygtrf        

  • get any worker machine created by the installer and save it as yaml to copy required info from it if needed

oc get machines.machine.openshift.io ocp-ksvrj-worker-0 -oyaml -n openshift-machine-api        

  • create below new worker static file

apiVersion: machine.openshift.io/v1beta1
kind: Machine
metadata:
  creationTimestamp: null
  labels:
    machine.openshift.io/cluster-api-cluster: ocp-ygtrf
    machine.openshift.io/cluster-api-machine-role: worker
    machine.openshift.io/cluster-api-machine-type: worker
    node-role.kubernetes.io/worker: ""
    node-role.kubernetes.io: worker
  name: <cluster-id>-worker-<number>
  namespace: openshift-machine-api
spec:
  lifecycleHooks: {}
  metadata: {}
  providerSpec:
    value:
      apiVersion: machine.openshift.io/v1beta1
      credentialsSecret:
        name: vsphere-cloud-credentials
      diskGiB: 150
      kind: VSphereMachineProviderSpec
      memoryMiB: 32768
      metadata:
        creationTimestamp: null
      network:
        devices:
        - gateway: <gw>
          ipAddrs:
          - <ip/24>
          nameservers:
          - <dns1>
          - <dns2>
          networkName: <network-name>
      numCPUs: 8
      numCoresPerSocket: 4
      snapshot: ""
      template: <template>
      userDataSecret:
        name: worker-user-data
      workspace:
        datacenter: <datacenter>
        datastore: </datacenter/datastore/datastore>
        folder: </datacenter/vm/folder>
        resourcepool: </datacenter/host/cluster/Resources>
        server: <vcenter>
        

and finally the magic happened once applied the file, new worker node we will be created with static configured IP.

Hope you have enjoyed reading with about that new feature in OPC 4.14.

all examples in this article tested on OCP 4.14.10 and VMware 7.

for more info about OCP IPI Installation OCP_IPI_VMware

for more info about IPI on VMware using Static IP OCP_IPI_VMware_Static_IP

If you need to know anything about Openshift please feel free to contact me and read my past articles maybe it helps.

Subscribe on LinkedIn https://www.dhirubhai.net/build-relation/newsletter-follow?entityUrn=6909177885404622848

Mohamed Hendy

Systems & Virtualization Manager at Network International (RHCSA | VCA | VCP-DCV | VCP-CMA | VCP-NV NSX-T | 2x Azure 900&104 | NCP-MCI | NCA-MCI | 2x NSE | CCNA)

8 个月

Impressive ya Remooo??

要查看或添加评论,请登录

Remon Ibrahim的更多文章

  • OCP4 Tips P.09/machine set deletion policy

    OCP4 Tips P.09/machine set deletion policy

    Hello All, Hope all of you are doing well, in today's article we will talk about machine set what is it why we need…

    2 条评论
  • Ansible Automation without Playbooks

    Ansible Automation without Playbooks

    Hello Everyone, In today's articles we are going to talk about ansible, most of you know ansible as it is a…

    3 条评论
  • OCP4 Tips P.08/Scheduler vs node Requests vs node Utilization

    OCP4 Tips P.08/Scheduler vs node Requests vs node Utilization

    Hi All, Did you ever ask yourself about the following questions: what will happen if we run all pods without defining…

    4 条评论
  • OCP4 Tips P.06/OpenShift Advanced Cluster Management (ACM)

    OCP4 Tips P.06/OpenShift Advanced Cluster Management (ACM)

    Hello All, we have talked before about OpenShift day 2 operations, and we saw that are many tasks you need to do after…

    1 条评论
  • OCP4 Tips P.05/OpenShift MachineSets with VMware Environment

    OCP4 Tips P.05/OpenShift MachineSets with VMware Environment

    Hello Everyone, In this week, our article will be about Openshift MachineSets , what they are, where are they used in…

  • OCP4 Tips P.04/Day 2 Operations

    OCP4 Tips P.04/Day 2 Operations

    Hello Everyone, today will answer one of the important questions, what should we do after day 1 implementation/install…

    5 条评论
  • VSphere Automation with PowerCLI part 03

    VSphere Automation with PowerCLI part 03

    Hello Everyone This is our third article in Vsphere Automation with PowerCLI ,if you still didn't read the others you…

    1 条评论
  • OCP4 Tips P.03/Change Node NTP Configuration and Time Zone

    OCP4 Tips P.03/Change Node NTP Configuration and Time Zone

    Hello Everyone, In this article we will talk on how to change node NTP configuration and time zone things you need to…

  • OCP4 Tips P.02/Change API Cert

    OCP4 Tips P.02/Change API Cert

    Hello Everyone, this is our second article in Openshift Tips and Tricks Series, In the first article we talked about…

    1 条评论
  • OCP4 Tips P.01/Change Ingress Cert

    OCP4 Tips P.01/Change Ingress Cert

    Hello Everyone In this series of articles I will share with you some Openshift tips and tricks that I found them very…

    3 条评论

社区洞察

其他会员也浏览了