环境信息:
162.3.160.60 kolla, 部署节点,不跑业务pod
kubernetes集群信息:
162.3.160.61 kubernetes master节点,主要利用kubeadm部署的kubernetes 服务,不跑业务pod
162.3.160.62 kubernetes node1节点
162.3.160.63 kubernetes node2节点
各个节点都是centos7操作系统,节点需要:
-
2 network interfaces
-
8GB main memory
-
40GB disk space
-
Kubernetes的安装
请参考【转】使用kubeadm安装Kubernetes 1.7
二、kolla节点安装kubectl,并能够调用kubectl命令访问kubernetes集群。
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
yum install -y kubectl
在kubernetes master节点上把kubeconfig信息拷贝到kolla节点上,在kolla节点上创建/root/.kube目录
mkdir -p /root/.kube
scp /etc/kubernetes/admin.conf root@162.3.160.60:/root/.kube/config
在kolla节点上,利用命令kubectl get pods --all-namespaces 测试是否正常
-
部署kolla-kubernetes
-
更新默认的rbac设置
kubectl update -f <(cat <<EOF
apiVersion: rbac.authorization.k8s.io/v1alpha1
kind: ClusterRoleBinding
metadata:
name: cluster-admin
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: Group
name: system:masters
- kind: Group
name: system:authenticated
- kind: Group
name: system:unauthenticated
EOF
)
-
安装helm工具
curl -L https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
chmod 700 get_helm.sh
./get_helm.sh
helm init
kubectl get pods --all-namespaces 查看tiller是否安装。
生成配置文件
kolla-ansible -p /usr/share/kolla-kubernetes/ansible/site.yml genconfig
部署数据库mysql
helm install --debug kolla-kubernetes/helm/service/mariadb --namespace kolla --name mariadb --values ./cloud.yaml
部署mariadb
Mariadb容器的状态一直不正常,去容器里面查看日志/var/log/kolla/mariadb/mariadb.log,错误信息如下:
170925 14:49:03 [Note] /usr/sbin/mysqld (mysqld 10.0.31-MariaDB-wsrep) starting as process 313 ...
170925 14:49:03 [Note] WSREP: Read nil XID from storage engines, skipping position init
170925 14:49:03 [Note] WSREP: wsrep_load(): loading provider library '/usr/lib64/galera/libgalera_smm.so'
170925 14:49:03 [Note] WSREP: wsrep_load(): Galera 25.3.20(r3703) by Codership Oy <info@codership.com> loaded successfully.
170925 14:49:03 [Note] WSREP: CRC-32C: using hardware acceleration.
170925 14:49:03 [ERROR] WSREP: Bad value for 'node_address': '0.0.0.0': 22 (Invalid argument)
at galera/src/replicator_smm_params.cpp:InitConfig():85
170925 14:49:03 [ERROR] WSREP: wsrep::init() failed: 7, must shutdown
170925 14:49:03 [ERROR] Aborting
我们修改mariadb的配置项来规避此问题:
1、生成mariadb 配置文件:
kubectl get configmap mariadb -n kolla -o yaml > mariadb_conf.yaml
2、去掉wsrep_node_address = 0.0.0.0:4567,用服务默认的配置
-
更新mariadb配置项
kubectl replace --force -f mariadb_conf.yaml
-
重新部署mariadb
注意:
利用helm del mariadb --purge 清理mariadb时,可能有一个job 是mariadb-init-element的删除不掉,需要手动删除一下。
部署数据库失败或者想清理完全数据库,一定要到mariadb容器跑的节点上,把目录下/var/lib/kolla/volumes/mariadb/的文件进行清理,否则重新部署mariadb会失败。
rm -fr /var/lib/kolla/volumes/mariadb/*
部署rabbitmq
helm install --debug kolla-kubernetes/helm/service/rabbitmq --namespace kolla --name rabbitmq --values ./cloud.yaml
问题:
Rabbitmq 容器启动不起来,报错信息
Clusterer stoping node now
我们修改rabbitmq的配置项来规避此问题:
-
生成rabbitmq配置文件:
kubectl get configmap rabbitmq -n kolla -o yaml > rabbitmq_conf.yaml
2、修改rabbitmq-clusterer.config配置
修改成:
rabbitmq-clusterer.config: |
[
{version, 1},
{nodes, [
{'rabbit@rabbitmq-0', disc} ]},
{gospel,
{node, 'rabbit@rabbitmq-0'}}
].
rabbitmq-0 为你pod的名称
-
更新rabbitmq配置项
kubectl replace --force -f rabbitmq_conf.yaml
4、重新部署rabbitmq
rabbitmq就能正常运行了
注意:
利用helm del rabbitmq --purge 清理rabbitmq时,可能有一个job 是rabbitmq-init-element的删除不掉,需要手动删除一下。
部署rabbitmq失败,一定要到rabbitmq容器跑的节点上,把目录下/var/lib/kolla/volumes/rabbitmq/的文件进行清理,否则重新部署rabbitmq会失败,因为有残留的rabbitmq-clusterer.config文件存在。
rm -fr /var/lib/kolla/volumes/rabbitmq/*
部署keystone
helm install --debug kolla-kubernetes/helm/service/keystone --namespace kolla --name keystone --values ./cloud.yaml
生成openstack环境变量:
kolla-kubernetes/tools/build_local_admin_keystonerc.sh
ext
source
~/keystonerc_admin
安装openstack 客户端
yum install -y python-openstackclient
注意:
2017-09-29 20:35:31.259 13 INFO keystone.common.fernet_utils [-] Created a new temporary key: /etc/keystone/fernet-keys/0.tmp
2017-09-29 20:35:31.260 13 INFO keystone.common.fernet_utils [-] Current primary key is: 0
2017-09-29 20:35:31.260 13 INFO keystone.common.fernet_utils [-] Next primary key will be: 1
2017-09-29 20:35:31.260 13 INFO keystone.common.fernet_utils [-] Promoted key 0 to be the primary: 1
2017-09-29 20:35:31.261 13 INFO keystone.common.fernet_utils [-] Become a valid new key: /etc/keystone/fernet-keys/0
curl: (22) NSS: client certificate not found (nickname not specified)
可能原因是keystone-fernet-keys 这个secret已经存在了,所以报上面的错误
清理keystone资源:
helm del keystone --purge
kubectl delete secret keystone-fernet-keys -n kolla
清理keystone数据库:
登录mariadb容器:
mysql -h localhost -u root -p
drop database keystone;
部署glance
helm install --debug kolla-kubernetes/helm/service/glance --namespace kolla --name glance --values ./cloud.yaml
安装glanceclient
yum install -y python-glanceclient
多次重试部署失败现象一:
openstack endpoint create --region RegionOne image admin http://glance-api:9292
Multiple service matches found for 'image', use an ID to be more specific.
解决方案:去掉多个type为image的多个service
openstack service list
+----------------------------------+----------+----------+
| ID | Name | Type |
+----------------------------------+----------+----------+
| 3743175297fb4ca093d0a4565a0133ae | glance | image |
| 60147cf9c09e4311826ddfa8f17c3709 | glance | image |
| 666eb470d84446189d3825646e550bd8 | keystone | identity |
| 7baa8a699dc8457ea352f44b7411575c | glance | image |
openstack service delete 3743175297fb4ca093d0a4565a0133ae 60147cf9c09e4311826ddfa8f17c3709
openstack service show glance && openstack service delete glance
部署cinder-control
清理资源
helm del cinder-control --purge
openstack service show cinder && openstack service delete cinder
openstack service show cinderv2 && openstack service delete cinderv2
部署horizon
helm install --debug kolla-kubernetes/helm/service/horizon --namespace kolla --name horizon --values ./cloud.yaml
部署openvswitch
helm install --debug kolla-kubernetes/helm/service/openvswitch --namespace kolla --name openvswitch --values ./cloud.yaml