• OCP安装定制文件准备


    NSX ALB + Harbor + OpenShift 4.8 UPI安装配置实验笔记系列目录

    目录

    1 声明基础临时环境变量

    2 为RHCOS的core用户准备ssh key

    3 基于本地Registry的Image解压openshift-install安装程序

    4 生成install-config.yaml文件

    4.1 准备本地Registry证书

    4.2 使用变量生成install-config.yaml文件

    5 生成ignition文件

    5.1 启用Operator主机的http服务

    5.2 创建mainfest文件

    5.3 按需修改配置文件

    5.3.1 修改应用默认域名

    5.3.2 配置NTP

    5.4 生成Ignition文件

    5.5 创建Ignition引导文件http下载目录


    1 声明基础临时环境变量

    因OpenShift会有版本更新情况,当非连续性操作时,可在此使用实际我们上面Download下来的RELEASE版本号更从新声明变量:

    1. export OCP_RELEASE=4.8.36
    2. export RHCOS_RELEASE=4.8.14
    3. export LOCAL_REGISTRY='map.corp.tanzu'
    4. export LOCAL_REPOSITORY='openshift/ocp4.8.36'
    5. export PRODUCT_REPO='openshift-release-dev'
    6. export RELEASE_NAME='ocp-release'
    7. export ARCHITECTURE='x86_64'
    8. export OCP_PATH=/data/OCP-${OCP_RELEASE}/ocp
    9. export LOCAL_SECRET_JSON=${OCP_PATH}/secret/pull-secret.json
    10. export REMOVABLE_MEDIA_PATH=${OCP_PATH}/ocp-image
    11. export BOOT_FILE_PATH=/data/boot-files
    12. export RHCOS_ISO_PATH=${BOOT_FILE_PATH}/rhcos-iso
    13. export DOMAIN=corp.tanzu
    14. export OCP_CLUSTER_ID=ocp
    15. export OPERATOR_DOMAIN=operator.${DOMAIN}
    16. export IGN_PATH=${BOOT_FILE_PATH}/ignition/${OCP_CLUSTER_ID}

    2 为RHCOS的core用户准备ssh key

    1). 在安装文件目录“/data/boot-files/ignition/ocp”建个ssh-key目录,用于存放我们生成的ssh key:

    1. mkdir -p ${IGN_PATH}/ssh-key
    2. ssh-keygen -t rsa -b 4096 -N '' -f ${IGN_PATH}/ssh-key/id_rsa
    3. eval "$(ssh-agent -s)"
    4. ssh-add ${IGN_PATH}/ssh-key/id_rsa

    2). 为生成的ssh key声明环境变量:

    1. export SSH_PRI_FILE=${IGN_PATH}/ssh-key/id_rsa
    2. export SSH_PUB_STR=$(cat ${IGN_PATH}/ssh-key/id_rsa.pub)

    3 基于本地Registry的Image解压openshift-install安装程序

    1. oc adm release extract -a ${LOCAL_SECRET_JSON} --command=openshift-install "${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}:${OCP_RELEASE}-${ARCHITECTURE}"
    2. cp openshift-install /usr/sbin/
    3. openshift-install version

    4 生成install-config.yaml文件

    4.1 准备本地Registry证书

    将本地Registry的CA证书copy至准备目录:

    cp /etc/pki/ca-trust/source/anchors/map-harbor.crt ${IGN_PATH}

    4.2 使用变量生成install-config.yaml文件

    1). 在Operator主机输入以下命令信息,此命令使用变量在yaml文件中同时更新了PullSecret、sshKey、本地Registry的ca证书、还有本地Registry的域名等信息:

    1. cat << EOF > ${IGN_PATH}/install-config.yaml
    2. apiVersion: v1
    3. baseDomain: ${DOMAIN}
    4. compute:
    5. - hyperthreading: Enabled
    6. name: worker
    7. replicas: 0
    8. controlPlane:
    9. hyperthreading: Enabled
    10. name: master
    11. replicas: 3
    12. metadata:
    13. name: ${OCP_CLUSTER_ID}
    14. networking:
    15. clusterNetworks:
    16. - cidr: 100.224.0.0/16
    17. hostPrefix: 24
    18. networkType: OpenShiftSDN
    19. serviceNetwork:
    20. - 100.225.0.0/16
    21. platform:
    22. none: {}
    23. fips: false
    24. pullSecret: '$(awk -v RS= '{$1=$1}1' ${LOCAL_SECRET_JSON})'
    25. sshKey: '${SSH_PUB_STR}'
    26. additionalTrustBundle: |
    27. $(cat ${IGN_PATH}/map-harbor.crt | sed 's/^/ /g' | sed 's/^/ /g')
    28. imageContentSources:
    29. - mirrors:
    30. - ${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}
    31. source: quay.io/openshift-release-dev/ocp-release
    32. - mirrors:
    33. - ${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}
    34. source: quay.io/openshift-release-dev/ocp-v4.0-art-dev
    35. EOF

    2). 完成后使用以下命令查看一下yaml文件的内容:

    more ${IGN_PATH}/install-config.yaml

    3). 确认没有问题后,可以将其备份一份,因为生成ignition过程中此yaml会被销毁:

    cp ${IGN_PATH}/install-config.yaml{,.`date '+%s'`.bak}

    5 生成ignition文件

    注:创建完ignition文件后,必须在24小时内完成OpenShift集群的创建,否则证书会过期失效。

    5.1 启用Operator主机的http服务

    1. yum -y install httpd
    2. systemctl enable httpd
    3. systemctl start httpd
    4. systemctl status httpd

    5.2 创建mainfest文件

    1). 创建mainfest文件

    openshift-install create manifests --dir ${IGN_PATH}

    2). 查看成生成的结果

    tree ${IGN_PATH}/manifests/ ${IGN_PATH}/openshift/

    3). 修改Master节点不参与业务POD调度配置(可选 )

    sed -i 's/mastersSchedulable: true/mastersSchedulable: false/g' ${IGN_PATH}/manifests/cluster-scheduler-02-config.yml

    4). 检查配置结果

    cat ${IGN_PATH}/manifests/cluster-scheduler-02-config.yml

    5.3 按需修改配置文件

    5.3.1 修改应用默认域名

    Openshift应用默认子域名为“apps”,如需要调,可在此时修改cluster-ingress-02-config.yml内的参数,此ymal文件内容如下:

    修改命令如下,修改域名为dev.ocp.corp.tanzu:

    sed -i 's/apps.ocp/dev.ocp/g' ${IGN_PATH}/manifests/cluster-ingress-02-config.yml

     

    5.3.2 配置NTP

    1). 分别为worker和master生成chrony.bu文件,具体如下:

    Worker

    1. cat << EOF > 99-worker-chrony.bu
    2. variant: openshift
    3. version: 4.8.0
    4. metadata:
    5. name: 99-worker-chrony
    6. labels:
    7. machineconfiguration.openshift.io/role: worker
    8. storage:
    9. files:
    10. - path: /etc/chrony.conf
    11. mode: 0644
    12. overwrite: true
    13. contents:
    14. inline: |
    15. pool 192.168.100.1 iburst
    16. driftfile /var/lib/chrony/drift
    17. makestep 1.0 3
    18. rtcsync
    19. logdir /var/log/chrony
    20. EOF

    Master

    1. cat << EOF > 99-master-chrony.bu
    2. variant: openshift
    3. version: 4.8.0
    4. metadata:
    5. name: 99-master-chrony
    6. labels:
    7. machineconfiguration.openshift.io/role: master
    8. storage:
    9. files:
    10. - path: /etc/chrony.conf
    11. mode: 0644
    12. overwrite: true
    13. contents:
    14. inline: |
    15. pool 192.168.100.1 iburst
    16. driftfile /var/lib/chrony/drift
    17. makestep 1.0 3
    18. rtcsync
    19. logdir /var/log/chrony
    20. EOF

    2). 生成对应的yaml文件,并存入安装路径下的openshift目录中:

    1. butane 99-worker-chrony.bu -o ${IGN_PATH}/openshift/99-worker-chrony.yaml
    2. butane 99-master-chrony.bu -o ${IGN_PATH}/openshift/99-master-chrony.yaml

    3). 如果环境已安装,则可以用以下命令应用:

    1. oc apply -f 99-worker-chrony.yaml
    2. oc apply -f 99-master-chrony.yaml

    5.4 生成Ignition文件

    在我们安装目录中生成ignition文件并查看生成结果:

    1. openshift-install create ignition-configs --dir ${IGN_PATH}/
    2. ls -al ${IGN_PATH}/*.ign

    5.5 创建Ignition引导文件http下载目录

    1). 给安装文件目录配置权限:

    1. chmod -R 755 ${IGN_PATH}
    2. chmod -R 600 ${IGN_PATH}/ssh-key

    注:如果ssh-key目录或文件权限过大,在ssh时会有“Permissions 0755 for '/data/boot-files/ignition/ocp/ssh-key/id_rsa' are too open.”报错提示。

    2). 配置httpd config:

    1. cat << EOF > /etc/httpd/conf.d/ignition.conf
    2. Alias /ignition "${IGN_PATH}/../"
    3. <Directory "${IGN_PATH}/../">
    4. Options +Indexes +FollowSymLinks
    5. Require all granted
    6. </Directory>
    7. <Location /ignition >
    8. SetHandler None
    9. </Location>
    10. EOF

    3). 重启http服务:

    systemctl restart httpd

    4). 检查此http服务是否正常

    curl http://${OPERATOR_DOMAIN}/ignition/ocp/

     

  • 相关阅读:
    HTML + CSS: 实现Tab导航栏(一)
    1.3.19 网络端口地址转换 NAPT 配置
    windows安装zabbix-agent
    Unity技术手册-UGUI零基础详细教程-ScrollBar和ScrollView
    ToDoList全局事件总线学习笔记
    解读文献中的箱线图(Box-plot)和小提琴图(Violin-plot))
    CSS 线条流转 login
    系统架构设计师-计算机网络
    Logstash同步MySQL数据到ES
    【从零开始学习 SystemVerilog】3.7、SystemVerilog 控制流—— Functions(函数)
  • 原文地址:https://blog.csdn.net/frank0521/article/details/125475090