備忘録:OpenShift 3.7 を All in One でインストール
いつもAzureを使っているので、AWSも使ってみようと OpenShift の All in One の環境をデプロイした時のメモ。
AWSのインスタンスへの設定
- publicの固定IPを付与するために Elastic IPを設定
- 管理コンソール(8443)、Web App(80, 443)のInbound accessを許可するためにSecurity Groupを設定
OpenShift のインストール
必要なパッケージのインストール
subscription-manager で登録した後は、必要なパッケージのインストール
subscription-manager repos --disable="*" subscription-manager repos \ --enable="rhel-7-server-rpms" \ --enable="rhel-7-server-extras-rpms" \ --enable="rhel-7-server-ose-3.7-rpms" \ --enable="rhel-7-fast-datapath-rpms" yum -y install wget git net-tools bind-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct yum -y update yum -y install atomic-openshift-utils yum -y install atomic-openshift-excluder atomic-openshift-docker-excluder atomic-openshift-excluder unexclude yum -y install docker sed -i '/OPTIONS=.*/c\OPTIONS="--selinux-enabled --insecure-registry 172.30.0.0/16"' /etc/sysconfig/docker systemctl enable docker systemctl start docker
インベントリファイル
Docker用のストレージを作らなかったり、リソースが少なめだったりするので事前チェックをすり抜けるためのパラメータ openshift_disable_check=memory_availability,disk_availability,docker_storage
を設定
!!!本当は、ちゃんとシステム要件を満たすリソースを割りあてないとダメです!!!
[OSEv3:children] masters nodes etcd # Set variables common for all OSEv3 hosts [OSEv3:vars] # SSH user, this user should allow ssh based auth without requiring a password ansible_ssh_user=ec2-user # If ansible_ssh_user is not root, ansible_become must be set to true ansible_become=true openshift_deployment_type=openshift-enterprise openshift_disable_check=memory_availability,disk_availability,docker_storage openshift_master_default_subdomain=000.000.000.000.nip.io # uncomment the following to enable htpasswd authentication; defaults to DenyAllPasswordIdentityProvider openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '/etc/origin/master/htpasswd'}] # host group for masters [masters] ec2-000-000-000-000.ap-northeast-1.compute.amazonaws.com # host group for etcd [etcd] ec2-000-000-000-000.ap-northeast-1.compute.amazonaws.com # host group for nodes, includes region info [nodes] ec2-000-000-000-000.ap-northeast-1.compute.amazonaws.com openshift_schedulable=true openshift_node_labels="{'region': 'infra', 'zone': 'default'}" openshift_public_hostname=ec2-000-000-000-000.ap-northeast-1.compute.amazonaws.com openshift_hostname=ip-172-31-000-000.ap-northeast-1.compute.internal
PV を NFS で提供
NFS サーバの設定
パッケージのインストール
yum -y install nfs-utils
NFS の設定
mkdir -p /var/export/pvs/pv{1..10} chown -R nfsnobody:nfsnobody /var/export/pvs chmod -R 2770 /var/export/pvs for volume in pv{1..10} ; do echo Creating export for volume $volume; echo "/var/export/pvs/${volume} *(rw,sync,root_squash)" >> /etc/exports; done; systemctl enable rpcbind nfs-server systemctl start rpcbind nfs-server nfs-lock nfs-idmap systemctl stop firewalld systemctl disable firewalld setsebool -P virt_use_nfs=true;
で、動作確認
ssh [クライアントIPアドレス] mkdir /tmp/test mount -v [NFSサーバ名]:/var/export/pvs/pv1 /tmp/test umount /tmp/test exit
PV の作成
PV の定義作成
export volsize=1Gi for volume in pv{1..10} ; do cat << EOF > ${volume}.yaml { "apiVersion": "v1", "kind": "PersistentVolume", "metadata": { "name": "${volume}" }, "spec": { "capacity": { "storage": "${volsize}" }, "accessModes": [ "ReadWriteOnce" ], "nfs": { "path": "/var/export/pvs/${volume}", "server": "$NFS_SERVER" }, "persistentVolumeReclaimPolicy": "Recycle" } } EOF echo "Created def file for ${volume}"; done;
PVの作成
for f in *.yaml; do oc create -f $f; done
トラブルシューティング
Service Catalog がデプロイされない問題
Bug 1523625 – service catalog deployment fails
こんな感じで、kube-service-catalog プロジェクトの controller-manager がちゃんとデプロイされていない場合。
$ oc get po --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE kube-service-catalog controller-manager-8r8vt 0/1 CrashLoopBackOff 19 1d
まずは、
oc logs controller-manager-8r8vt --previous
で、ログを確認して証明書のエラーが発生している場合は、証明書を置き換えてあげる必要があります。
エラーの例
F1206 08:45:28.713230 1 controller_manager.go:198] error running controllers: failed to get supported resources from server: unable to retrieve the complete list of server APIs: servicecatalog.k8s.io/v1beta1: an error on the server ("Error: 'x509: certificate signed by unknown authority (possibly because of \"crypto/rsa: verification error\" while trying to verify candidate authority certificate \"service-catalog-signer\")'\nTrying to reach: 'https://172.30.72.245:443/apis/servicecatalog.k8s.io/v1beta1' ") has prevented the request from succeeding
以下の手順で証明書を書き換えます。
cat /etc/origin/service-catalog/ca.crt | base64 =>結果をコピーして、1行にまとめておく oc edit apiservice/v1beta1.servicecatalog.k8s.io =>ca_bundleフィールドを置き換える
追記
2018-03-23
docker-1.12.x をインストールしているにもかかわらず、docker-1.13 のリポジトリが見えているというエラーが発生する場合は、openshift_disable_check
パラメータにpackage_version
を指定する。
openshift_disable_check=memory_availability,disk_availability,docker_storage,package_version