1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | cat > nginx-cinder.yaml << END apiVersion: v1 kind: Pod metadata: name: aws-web spec: containers: - name: web image: nginx ports: - name: web containerPort: 80 hostPort: 8081 protocol: TCP volumeMounts: - name: html-volume mountPath: "/usr/share/nginx/html" volumes: - name: html-volume cinder: # Enter the volume ID below volumeID: $ID fsType: ext4 END |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | cd /opt/stack/magnum cp /opt/stack/tempest/etc/tempest.conf /opt/stack/magnum/etc/tempest.conf cp functional_creds.conf.sample functional_creds.conf # update the IP address HOST=$(cat /etc/magnum/magnum.conf | awk '/^host = /{print $3}') sed -i "s/127.0.0.1/$HOST/" functional_creds.conf # update admin password source /opt/stack/devstack/openrc admin admin iniset functional_creds.conf admin pass $OS_PASSWORD # update demo password source /opt/stack/devstack/openrc demo demo iniset functional_creds.conf auth password $OS_PASSWORD Set the DNS name server to be used in your bay nodes (e.g. 8.8.8.8):: # update DNS name server source /opt/stack/devstack/openrc demo demo iniset functional_creds.conf magnum dns_nameserver Create the necessary keypair and flavor:: source /opt/stack/devstack/openrc admin admin nova keypair-add --pub-key ~/.ssh/id_rsa.pub default nova flavor-create m1.magnum 100 1024 10 1 nova flavor-create s1.magnum 200 512 10 1 source /opt/stack/devstack/openrc demo demo nova keypair-add --pub-key ~/.ssh/id_rsa.pub default Upgrade packages:: UPPER_CONSTRAINTS=/opt/stack/requirements/upper-constraints.txt sudo pip install -c $UPPER_CONSTRAINTS -U -r test-requirements.txt |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | [auth] use_dynamic_credentials=False test_accounts_file=/tmp/etc/magnum/accounts.yaml admin_username=admin admin_password=password admin_project_name=admin [identity] disable_ssl_certificate_validation=True uri=https://identity.example.com/v2.0 auth_version=v2 region=EAST [identity-feature-enabled] api_v2 = true api_v3 = false trust = false [oslo_concurrency] lock_path = /tmp/ [magnum] image_id=22222222-2222-2222-2222-222222222222 nic_id=11111111-1111-1111-1111-111111111111 keypair_id=default flavor_id=small magnum_url=https://magnum.example.com/v1 [debug] trace_requests=true |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | Create a file (e.g nginx.yaml) describing a pod running nginx:: apiVersion: v1 kind: Pod metadata: name: nginx labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 Create a file (e.g nginx-service.yaml) describing a service for the nginx pod:: apiVersion: v1 kind: Service metadata: name: nginxservice labels: app: nginx spec: ports: - port: 80 targetPort: 80 protocol: TCP selector: app: nginx type: LoadBalancer |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | neutron floatingip-create public Created a new floatingip: +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | fixed_ip_address | | | floating_ip_address | 172.24.4.78 | | floating_network_id | 4808eacb-e1a0-40aa-97b6-ecb745af2a4d | | id | b170eb7a-41d0-4c00-9207-18ad1c30fecf | | port_id | | | router_id | | | status | DOWN | | tenant_id | 012722667dc64de6bf161556f49b8a62 | +---------------------+--------------------------------------+ //查询floating ip FLOATING_ID=$(neutron floatingip-list | grep "172.24.4.78" | awk '{print $2}') //在load-balancer上查询VIP VIP_ID=$(neutron lb-vip-list | grep TCP | grep -v pool | awk '{print $2}') //在VIP上找到port PORT_ID=$(neutron lb-vip-show $VIP_ID | grep port_id | awk '{print $4}') //绑定floating ip到VIP的port上 neutron floatingip-associate $FLOATING_ID $PORT_ID //这样ngnix就可以通过下面地址被访问了 http://172.24.4.78:80 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | $ sudo apt-get update $ sudo apt-get install git qemu-utils python-pip $ git clone https://git.openstack.org/openstack/magnum $ git clone https://git.openstack.org/openstack/diskimage-builder.git $ git clone https://git.openstack.org/openstack/dib-utils.git $ git clone https://git.openstack.org/openstack/tripleo-image-elements.git $ git clone https://git.openstack.org/openstack/heat-templates.git $ export PATH="${PWD}/dib-utils/bin:$PATH" $ export ELEMENTS_PATH=tripleo-image-elements/elements:heat-templates/hot/software-config/elements:magnum/magnum/templates/mesos/elements $ export DIB_RELEASE=trusty $ diskimage-builder/bin/disk-image-create ubuntu vm docker mesos \ os-collect-config os-refresh-config os-apply-config \ heat-config heat-config-script \ -o ubuntu-mesos.qcow2 $ glance image-create --name ubuntu-mesos --visibility public \ --disk-format=qcow2 --container-format=bare \ --os-distro=ubuntu --file=ubuntu-mesos.qcow2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | //查看glance image glance -v image-list //查看container的service magnum service-list //创建一个keypair test -f ~/.ssh/id_rsa.pub || ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa nova keypair-add --pub-key ~/.ssh/id_rsa.pub testkey //创建一个baymodel magnum baymodel-create --name k8sbaymodel \ --image-id fedora-atomic-latest \ --keypair-id testkey \ --external-network-id public \ --dns-nameserver 8.8.8.8 \ --flavor-id m1.small \ --docker-volume-size 5 \ --network-driver flannel \ --coe kubernetes //创建bay magnum bay-create --name k8sbay --baymodel k8sbaymodel --node-count 1 //只有创建完bay之后,状态为CREATE_IN_PROGRESS,只有在状态变为CREATE_COMPLETE才能创建containers, pods, services, replication controllers,否则magnum的数据库则会混乱。 //查看bay magnum bay-list //查看bay的detail magnum bay-show k8sbay //在bay创建完成之后,可以动态的增加或减少nodes,例如增加一个node magnum bay-update k8sbay replace node_count=2 //注意:减少一个node数量会把该node上的所有pod全部删除,但是magnum会首先删除空的node,即没有pod跑在上面的node。magnum建议使用一个replication controller再删除node之前,这样在误删之后可以进行恢复。 //heat的stack就是magnum的bay //查看bay heat stack-list //查看特定的bay heat stack-show |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | //wget镜像 wget http://beta.release.core-os.net/amd64-usr/current/coreos_production_openstack_image.img.bz2 bunzip2 coreos_production_openstack_image.img.bz2 //上传镜像到glance:: glance image-create --name CoreOS \ --visibility public \ --disk-format=qcow2 \ --container-format=bare \ --os-distro=coreos \ --file=coreos_production_openstack_image.img //创建CoreOS Kubernetes baymodel,跟Atomic Kubernetes baymodel的创建是一样的 magnum baymodel-create --name k8sbaymodel-coreos \ --image-id CoreOS \ --keypair-id testkey \ --external-network-id public \ --dns-nameserver 8.8.8.8 \ --flavor-id m1.small \ --network-driver flannel \ --coe kubernetes \ --tls-disabled //创建CoreOS Kubernetes bay magnum bay-create --name k8sbay \ --baymodel k8sbaymodel-coreos \ --node-count 2 |
欢迎光临 51学通信论坛2017新版 (http://bbs.51xuetongxin.com/) | Powered by Discuz! X3 |