初始化环境
Director VM包含所有必须的BOSH组件,用于管理不同的IaaS资源。 如果想搭建一个本地化的环境,可以使用BOSH_lite。使用容器模拟虚拟机。
在openstack上初始化bosh环境
创建部署manifest
- 创建部署目录
$ mkdir ~/my-bosh
- 创建名为
bosh.yml
的部署manifest
---
name: bosh
releases:
- name: bosh
url: https://bosh.io/d/github.com/cloudfoundry/bosh?v=256.7
sha1: 6fa486378892737f5ad4409bcf4f122cb85c12d4
- name: bosh-openstack-cpi
url: https://bosh.io/d/github.com/cloudfoundry-incubator/bosh-openstack-cpi-release?v=25
sha1: 8ad0182d9cb6638bc216d7fa77d521390971e2a5
resource_pools:
- name: vms
network: private
stemcell:
url: https://bosh.io/d/stemcells/bosh-openstack-kvm-ubuntu-trusty-go_agent?v=3232.4
sha1: 7f974927463bb44d3580ee16f4a0e8b9fe89202d
cloud_properties:
instance_type: m1.xlarge
disk_pools:
- name: disks
disk_size: 20_000
networks:
- name: private
type: manual
subnets:
- range: PRIVATE-CIDR # <--- Replace with a private subnet CIDR
gateway: PRIVATE-GATEWAY-IP # <--- Replace with a private subnet's gateway
dns: [DNS-IP] # <--- Replace with your DNS
cloud_properties: {net_id: NETWORK-UUID} # <--- # Replace with private network UUID
- name: public
type: vip
jobs:
- name: bosh
instances: 1
templates:
- {name: nats, release: bosh}
- {name: postgres, release: bosh}
- {name: blobstore, release: bosh}
- {name: director, release: bosh}
- {name: health_monitor, release: bosh}
- {name: registry, release: bosh}
- {name: openstack_cpi, release: bosh-openstack-cpi}
resource_pool: vms
persistent_disk_pool: disks
networks:
- name: private
static_ips: [PRIVATE-IP] # <--- Replace with a private IP
default: [dns, gateway]
- name: public
static_ips: [FLOATING-IP] # <--- Replace with a floating IP
properties:
nats:
address: 127.0.0.1
user: nats
password: nats-password
postgres: &db
listen_address: 127.0.0.1
host: 127.0.0.1
user: postgres
password: postgres-password
database: bosh
adapter: postgres
registry:
address: PRIVATE-IP # <--- Replace with a private IP
host: PRIVATE-IP # <--- Replace with a private IP
db: *db
http: {user: admin, password: admin, port: 25777}
username: admin
password: admin
port: 25777
blobstore:
address: PRIVATE-IP # <--- Replace with a private IP
port: 25250
provider: dav
director: {user: director, password: director-password}
agent: {user: agent, password: agent-password}
director:
address: 127.0.0.1
name: my-bosh
db: *db
cpi_job: openstack_cpi
max_threads: 3
user_management:
provider: local
local:
users:
- {name: admin, password: admin}
- {name: hm, password: hm-password}
hm:
director_account: {user: hm, password: hm-password}
resurrector_enabled: true
openstack: &openstack
auth_url: IDENTITY-API-ENDPOINT # <--- Replace with OpenStack Identity API endpoint
tenant: OPENSTACK-TENANT # <--- Replace with OpenStack tenant name
username: OPENSTACK-USERNAME # <--- Replace with OpenStack username
api_key: OPENSTACK-PASSWORD # <--- Replace with OpenStack password
default_key_name: bosh
default_security_groups: [bosh]
agent: {mbus: "nats://nats:nats-password@PRIVATE-IP:4222"} # <--- Replace with a private IP
ntp: &ntp [0.pool.ntp.org, 1.pool.ntp.org]
cloud_provider:
template: {name: openstack_cpi, release: bosh-openstack-cpi}
ssh_tunnel:
host: FLOATING-IP # <--- Replace with a floating IP
port: 22
user: vcap
private_key: ./bosh.pem # Path relative to this manifest file
mbus: "https://mbus:mbus-password@FLOATING-IP:6868" # <--- Replace with a floating IP
properties:
openstack: *openstack
agent: {mbus: "https://mbus:[email protected]:6868"}
blobstore: {provider: local, path: /var/vcap/micro_bosh/data/cache}
ntp: *ntp
准备openstack环境
先决条件
- openstack版本,推荐Kilo
- 必须的组件
- Identity BOSH鉴定证书和获取其他endpoint的URL
- Compute 创建VMs 分配浮动IP给VMs,创建和attaches磁盘给VMs
- Image BOSH使用镜像服务存储stemcells
- (optional) Openstack networking 提供网络伸缩和自动管理功能,构建复杂的分布式系统时有用
- 以下openstack网络
- 一个对外的网络包含子网
- 一个私有网络包含子网,子网必须有IP地址分配池
- 配置新的openstack租户
- 可自动配置
- 手动配置 创建Keypair->创建安全组->分配浮动IP
创建Keypair
创建配置安全组
分配浮动IP
部署
- 安装 bosh-init
- 运行
bosh-init deploy ./bosh.yml
- 安装CLI
- 使用
bosh target FLOATING_IP_ADDRESS
to log into your new BOSH director。默认用户名密码是 admin admin - 保存部署状态文件