5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OpenShift 3.11インストール

Posted at

はじめに

OpenShift 環境を試したいので、CentOS7.7に OpenShift 3.11をインストール を導入します。

環境

CentOS 7.7 (CentOS 8 だと openshift-origin がyum でインストールできなかったため)
OpenShift OKD 3.11
ansible 2.7.10
all-in-one 構成にします。

OpenShift OKDのインストール

wheel groupのユーザーに権限を与えて導入します。nodeを分ける場合 openshift-ansibleはmasterノードだけ導入です

root#
echo "%wheel        ALL=(ALL)       NOPASSWD: ALL" > /etc/sudoers.d/wheel
chmod 440 /etc/sudoers.d/wheel
yum -y install epel-release docker gi centos-release-openshift-origin311 pyOpenSSL
systemctl enable docker
systemctl start docker
 

あとで実行するansibleの実行でエラーにならないようにバージョンを下げます。(OpenShiftの文書には Ansible 2.7 is not yet supported.とありますが、2.9 はエラーでしたが、2.7 はOKでした)

root#
yum -y install openshift-ansible
ansible --version
 
root#

curl -k https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
pip install ansible==2.7.10
ansible --version
 

ansible --versionが失敗する場合は以下を試す。

root#

pip install --upgrade pip
pip install --upgrade setuptools
 

OpenShiftの実行ユーザーにする wheelグループのメンバーで実行します。

wheel$
ssh-keygen -N "" -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
ssh $HOSTNAME ls
 
wheel$
sudo chown $USER /etc/ansible/hosts
sudo cat << EOS >> /etc/ansible/hosts
[OSEv3:children]
masters
nodes
etcd

[OSEv3:vars]
ansible_ssh_user=$USER
ansible_become=true
openshift_deployment_type=origin

# Authentication is htpasswd
openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider'}]
# Master 
openshift_master_default_subdomain=sub.$HOSTNAME
# Cluster internal subnet
openshift_docker_insecure_registries=172.30.0.0/16

[masters]
$HOSTNAME openshift_aschedulable=true containerized=false

[etcd]
$HOSTNAME

[nodes]
# [/usr/share/ansible/openshift-ansible/roles/openshift_facts/defaults/main.yml]
$HOSTNAME openshift_node_group_name='node-config-all-in-one'
EOS
sudo chown root /etc/ansible/hosts
 

メモリが 16GB以上あるときは -e openshift_disable_check=memory_availability の引数はいりません。メモリ不足で処理が遅かったためか、-e openshift_disable_check=memory_availability --limit @/usr/share/ansible/openshift-ansible/playbooks/openshift-master/config.retry の引数が必要でした。

wheel$
ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/prerequisites.yml
ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/deploy_cluster.yml -e openshift_disable_check=memory_availability
oc get nodes
oc get pods

ユーザー登録

OpenShiftを使うユーザーを登録します。adminが管理者でkeniooiが一般ユーザーです。oc login では htpasswd で登録したユーザーとパスワードを使います。

interactive-session-wheel$
sudo htpasswd /etc/origin/master/htpasswd admin
sudo htpasswd /etc/origin/master/htpasswd keniooi
oc adm policy add-cluster-role-to-user cluster-admin admin
oc login

ログインが確認できたらWebコンソールも確認します。kube-ではじまるようなプロジェクトが見えていれば、cluster-adminにも追加ができています。

image.png

おわり

ansible-playback の処理でエラーが発生しやすいです。ansibleのバージョンを下げる、エラーと合わせて表示されるオプションを引数に追加して実行をして試すと完了できました。

参考

https://www.unixarena.com/2019/06/downgrading-ansible-engine-on-centos-7-rhel-7.html/
https://www.unixarena.com/2019/06/how-to-install-pip-on-rhel-7-centos-7.html/
https://www.server-world.info/query?os=CentOS_7&p=openshift311&f=1
https://docs.okd.io/3.11/install/example_inventories.html
https://docs.openshift.com/container-platform/3.11/release_notes/ocp_3_11_release_notes.html

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?