CentOS 7はopenshift 3をインストールする.9クラスタ

7927 ワード

CentOS 7 openshiftクラスタのインストール

  • OpenShift公式サイト:https://www.openshift.com/
  • Github:https://github.com/openshift/origin

  • オープンソースコンテナアプリケーションプラットフォーム、OriginはOpenShiftをサポートする上流コミュニティプロジェクトです.DockerコンテナパッケージとKubernetesコンテナクラスタ管理のコア構築をめぐって、Originはアプリケーションライフサイクル管理機能とDevOpsツールを追加しました.Originは、完全なオープンソースコンテナアプリケーションプラットフォームを提供します.

    Red Hat OpenShiftのオープンソースバージョンであるOpenShift Originをインストールします

  • 環境CentOS 7:
  • Hostname
    Role
    IP
    master.aniu.so
    Master, etcd, and node
    192.168.0.111
    node1.aniu.so
    Computer Node
    192.168.0.114
    node2.aniu.so
    Computer Node
    192.168.0.115
    クラスタ構成リファレンス:https://docs.openshift.org/latest/install_config/install/planning.html
    クラスタの構成に必要なシステム要件
  • 主ノード少なくとも16 Gのメモリ
  • すべてのノードでは、Docker Direct LVMの新しいボリュームグループを作成するには、物理ボリューム上の空き領域が必要です.varディレクトリは少なくとも40 Gです.そうしないと、
  • には検出できません.

    ホストの設定

  • 依存パッケージをインストールし、ファイアウォールを閉じ、selinuxを無効にし、sysctl netを追加します.ipv4.ip_forward=1、すべてのノードで
  • を実行
    詳細は以下を参照してください.https://github.com/openshift/origin/blob/master/docs/cluster_up_down.md#prerequisites参照先:https://docs.openshift.org/latest/install_config/install/host_preparation.html#install-config-install-host-preparation
    yum install wget git net-tools bind-utils yum-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct -y
    yum install ansible pyOpenSSL -y
    
  • すべてのノードにOpenShift Origin 3.9リポジトリとDockerをインストールします.次に、Docker Direct LVMのボリュームグループを作成し、以下のようにLVM Thinpoolを設定します.
  • #  master  ,         
    [root@master ~]# yum -y install centos-release-openshift-origin37 docker
    [root@master ~]# vgcreate centos /dev/sdb1  #  vgname centos
    Volume group "centos" successfully created
    [root@master ~]# echo VG=centos >> /etc/sysconfig/docker-storage-setup 
    [root@master ~]# systemctl start docker 
    [root@master ~]# systemctl enable docker 
    
  • は、3つのノードmasterノードと他のノードsshとの機密保護を設定する.ansible-playbook
  • の実行を容易にする
    
    #  master     :
    [root@master ~]# ssh-keygen -t rsa
    #       
    [root@master ~]# cat /etc/hosts #     hosts,  hosts node1,node2
    127.0.0.1   localhost localhost.localdomain pinpoint
    ###########################################
    ## openshift
    192.168.0.113 master.aniu.so
    192.168.0.114 node1.aniu.so
    192.168.0.115 node2.aniu.so
    [root@master ~]# ssh-copy-id master.aniu.so
    /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    
    /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.
                    (if you think this is a mistake, you may want to use -f option)
    
    [root@master ~]# ssh-copy-id node1.aniu.so 
    /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    
    /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.
                    (if you think this is a mistake, you may want to use -f option)
    
    [root@master ~]# ssh-copy-id node2.aniu.so
    /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    
    /usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.
                    (if you think this is a mistake, you may want to use -f option)
    

    メインノードで、rootを使用してAnsible Playbookにログインして実行し、OpenShiftクラスタを設定します。

  • 参照:https://docs.openshift.org/latest/install_config/install/stand_alone_registry.html
  • yum -y install atomic-openshift-utils
    
      ansible hosts  :
    
    [root@master ~]# cat /etc/ansible/hosts 
    # add follows to the end
    [OSEv3:children]
    masters
    nodes
    etcd
    
    [OSEv3:vars]
    # admin user created in previous section
    ansible_ssh_user=root
    openshift_deployment_type=origin
    
    # use HTPasswd for authentication
    openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '/etc/origin/master/.htpasswd'}]
    openshift_master_default_subdomain=apps.test.aniu.so
    
    # allow unencrypted connection within cluster
    openshift_docker_insecure_registries=172.30.0.0/16
    
    [masters]
    master.aniu.so openshift_schedulable=true containerized=false
    
    [etcd]
    master.aniu.so
    
    [nodes]
    # set labels [region: ***, zone: ***] (any name you like)
    master.aniu.so openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
    node1.aniu.so openshift_node_labels="{'region': 'primary', 'zone': 'east'}" openshift_schedulable=true
    node2.aniu.so openshift_node_labels="{'region': 'primary', 'zone': 'west'}" openshift_schedulable=true
    
    
    #   deploy_cluster.yml       :
    ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/deploy_cluster.yml #       ,      2    。。。
    
  • 正常実行完了表示状態
  • -         :
    Error from server (Forbidden): nodes is forbidden: User "system:anonymous" cannot list nodes at the cluster scope: User "system:anonymous" cannot list all nodes in the cluster
        :
    [root@master ~]# oc login -u system:admin #   admin      
    Logged into "https://master.aniu.so:8443" as "system:admin" using existing credentials.
    
    You have access to the following projects and can switch between them with 'oc project ':
    
      * default
        kube-public
        kube-system
        logging
        management-infra
        openshift
        openshift-infra
        openshift-node
        openshift-web-console
    
    Using project "default".
    [root@master ~]# oc get nodes            
    NAME             STATUS    ROLES     AGE       VERSION
    master.aniu.so   Ready     master    4h        v1.9.1+a0ce1bc657
    node1.aniu.so    Ready         4h        v1.9.1+a0ce1bc657
    node2.aniu.so    Ready         4h        v1.9.1+a0ce1bc657
    [root@master ~]# oc get nodes --show-labels=true 
    NAME             STATUS    ROLES     AGE       VERSION             LABELS
    master.aniu.so   Ready     master    4h        v1.9.1+a0ce1bc657   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=master.aniu.so,node-role.kubernetes.io/master=true,region=infra,zone=default
    node1.aniu.so    Ready         4h        v1.9.1+a0ce1bc657   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=node1.aniu.so,region=primary,zone=east
    node2.aniu.so    Ready         4h        v1.9.1+a0ce1bc657   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=node2.aniu.so,region=primary,zone=west 
    

    Openshiftにログインするための新しいユーザーを作成

  • masterノードでユーザーを作成する:
  • [root@master ~]# htpasswd /etc/origin/master/.htpasswd aniu # 
    
  • 任意のオペレーティングシステムユーザーでログインし、OpenShiftクラスタにログインします.HTPasswdユーザー
  • を追加するだけです.
    [root@master ~]# oc login
    Authentication required for https://master.aniu.so:8443 (openshift)
    Username: aniu
    Password: 
    Login successful.
    
    You don't have any projects. You can try to create a new project, by running
    
        oc new-project 
    [root@master ~]# oc whoami
    aniu
    [root@master ~]# oc logout
    Logged "aniu" out on "https://master.aniu.so:8443"
    
  • は、Webブラウザを使用する任意のクライアントから管理コンソールにアクセスすることができる.[画像のアップロードに失敗しました...(image-ad 95 d 1-1527840854860)][画像のアップロードに失敗しました...(image-f 92 e 1 c-1527840854860)]