diff --git a/.github/workflows/action.yaml b/.github/workflows/action.yaml index 5d6c629..a0a8de2 100644 --- a/.github/workflows/action.yaml +++ b/.github/workflows/action.yaml @@ -5,8 +5,10 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - - name: hadolint - run: docker run --rm -i hadolint/hadolint < Dockerfile + - name: hadolint for controller + run: docker run --rm -i hadolint/hadolint < controller/Dockerfile + - name: hadolint for compute + run: docker run --rm -i hadolint/hadolint < compute/Dockerfile test: runs-on: ubuntu-20.04 steps: @@ -18,4 +20,4 @@ jobs: - name: Exec OpenStack CLI run: | docker-compose logs -t --tail=100 - docker-compose exec -T --user stack devstack /bin/bash -c 'source devstack/openrc admin admin; openstack compute service list' + docker-compose exec -T --user stack controller /bin/bash -c 'source devstack/openrc admin admin; openstack compute service list' diff --git a/README.md b/README.md index b78bf52..7e6fed4 100644 --- a/README.md +++ b/README.md @@ -13,19 +13,19 @@ This will take about 30 minutes. $ sudo docker-compose up -d $ sudo docker-compose logs -f -devstack_1 | This is your host IP address: 172.28.0.2 -devstack_1 | Horizon is now available at http://172.28.0.2/dashboard -devstack_1 | Keystone is serving at http://172.28.0.2/identity/ -devstack_1 | The default users are: admin and demo -devstack_1 | The password: nomoresecret -devstack_1 | -devstack_1 | Services are running under systemd unit files. -devstack_1 | For more information see: -devstack_1 | https://docs.openstack.org/devstack/latest/systemd.html -devstack_1 | -devstack_1 | DevStack Version: wallaby -devstack_1 | Change: -devstack_1 | OS Version: Ubuntu 20.04 focal +controller | This is your host IP address: 172.28.0.2 +controller | Horizon is now available at http://172.28.0.2/dashboard +controller | Keystone is serving at http://172.28.0.2/identity/ +controller | The default users are: admin and demo +controller | The password: nomoresecret +controller | +controller | Services are running under systemd unit files. +controller | For more information see: +controller | https://docs.openstack.org/devstack/latest/systemd.html +controller | +controller | DevStack Version: wallaby +controller | Change: +controller | OS Version: Ubuntu 20.04 focal ``` You can use the OpenStack CLI in the container. @@ -33,7 +33,7 @@ You can use the OpenStack CLI in the container. ```bash $ sudo docker-compose exec \ --user stack \ - devstack \ + controller \ /bin/bash -c 'source devstack/openrc admin admin; exec /bin/bash' stack@538b06c0fc0b:~$ openstack endpoint list diff --git a/Dockerfile b/compute/Dockerfile similarity index 78% rename from Dockerfile rename to compute/Dockerfile index 4684170..9ba1344 100644 --- a/Dockerfile +++ b/compute/Dockerfile @@ -13,9 +13,12 @@ RUN apt-get update \ iproute2=5.5.0-1ubuntu1 \ lsb=11.1.0ubuntu2 \ git=1:2.25.1-1ubuntu3.1 \ + curl=7.68.0-1ubuntu2.5 \ init=1.57 \ && apt-get -y clean \ && rm -rf /var/lib/apt/lists/* +RUN curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh > /bin/wait-for-it.sh \ + && chmod a+x /bin/wait-for-it.sh RUN useradd -s /bin/bash -d /opt/stack -m stack \ && mkdir -p /etc/sudoers.d/ \ @@ -26,8 +29,8 @@ RUN git clone https://github.com/openstack/devstack.git \ && git -C ./devstack checkout $DEVSTACK_COMMIT \ && chown -R stack:stack ./devstack -COPY local.conf /opt/stack/devstack/ -COPY devstack.service /etc/systemd/system/ +COPY compute/local.conf /opt/stack/devstack/ +COPY compute/devstack.service /etc/systemd/system/ COPY 0001-devstack-disable-ovs.patch /opt/stack/ RUN patch -d ./devstack -p1 < 0001-devstack-disable-ovs.patch diff --git a/compute/devstack.service b/compute/devstack.service new file mode 100644 index 0000000..e898bd0 --- /dev/null +++ b/compute/devstack.service @@ -0,0 +1,14 @@ +[Unit] +Description=devstack + +[Service] +User=stack +Type=oneshot +ExecStartPre=/bin/wait-for-it.sh -h 172.28.0.2 -p 80 -t 3600 +ExecStart=/opt/stack/devstack/stack.sh +ExecReload = /usr/bin/kill -HUP $MAINPID +KillMode = process +StandardOutput=tty + +[Install] +WantedBy=multi-user.target diff --git a/compute/local.conf b/compute/local.conf new file mode 100644 index 0000000..40395be --- /dev/null +++ b/compute/local.conf @@ -0,0 +1,19 @@ +[[local|localrc]] +ADMIN_PASSWORD=nomoresecret +DATABASE_PASSWORD=stackdb +RABBIT_PASSWORD=stackqueue +SERVICE_PASSWORD=$ADMIN_PASSWORD +LOGFILE=$DEST/logs/stack.sh.log +LOGDAYS=2 +SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5 +SWIFT_REPLICAS=1 +SWIFT_DATA_DIR=$DEST/data + +ENABLED_SERVICES=n-cpu,placement-client + +SERVICE_HOST=172.28.0.2 +MYSQL_HOST=$SERVICE_HOST +RABBIT_HOST=$SERVICE_HOST +GLANCE_HOSTPORT=$SERVICE_HOST:9292 + +[[post-config|$NOVA_CONF]] diff --git a/controller/Dockerfile b/controller/Dockerfile new file mode 100644 index 0000000..bf693fa --- /dev/null +++ b/controller/Dockerfile @@ -0,0 +1,40 @@ +FROM ubuntu:20.04 + +EXPOSE 80 5000 8773 8774 8775 8776 9292 +ENV DEBIAN_FRONTEND=noninteractive +ENV DEVSTACK_COMMIT=83821a11ac1d6738b63cb10878b8aaa02e153374 + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates=20210119~20.04.1 \ + patch=2.7.6-6 \ + systemd=245.4-4ubuntu3.5 \ + sudo=1.8.31-1ubuntu1.2 \ + iproute2=5.5.0-1ubuntu1 \ + lsb=11.1.0ubuntu2 \ + git=1:2.25.1-1ubuntu3.1 \ + curl=7.68.0-1ubuntu2.5 \ + init=1.57 \ + && apt-get -y clean \ + && rm -rf /var/lib/apt/lists/* +RUN curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh > /bin/wait-for-it.sh \ + && chmod a+x /bin/wait-for-it.sh + +RUN useradd -s /bin/bash -d /opt/stack -m stack \ + && mkdir -p /etc/sudoers.d/ \ + && echo "stack ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/stack + +WORKDIR /opt/stack +RUN git clone https://github.com/openstack/devstack.git \ + && git -C ./devstack checkout $DEVSTACK_COMMIT \ + && chown -R stack:stack ./devstack + +COPY controller/local.conf /opt/stack/devstack/ +COPY controller/devstack.service /etc/systemd/system/ +COPY 0001-devstack-disable-ovs.patch /opt/stack/ + +RUN patch -d ./devstack -p1 < 0001-devstack-disable-ovs.patch +RUN systemctl enable devstack + +STOPSIGNAL SIGRTMIN+3 +CMD [ "/sbin/init" ] diff --git a/devstack.service b/controller/devstack.service similarity index 100% rename from devstack.service rename to controller/devstack.service diff --git a/local.conf b/controller/local.conf similarity index 81% rename from local.conf rename to controller/local.conf index 93c22c1..e454bef 100644 --- a/local.conf +++ b/controller/local.conf @@ -10,7 +10,7 @@ SWIFT_REPLICAS=1 SWIFT_DATA_DIR=$DEST/data ENABLED_SERVICES=rabbit,mysql,key -ENABLED_SERVICES+=,n-api,n-crt,n-obj,n-cpu,n-cond,n-sch,placement-api,placement-client +ENABLED_SERVICES+=,n-api,n-crt,n-obj,n-cond,n-sch,placement-api,placement-client ENABLED_SERVICES+=,g-api,g-reg ENABLED_SERVICES+=,horizon diff --git a/docker-compose.yaml b/docker-compose.yaml index c17a9b9..e361273 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,6 +1,42 @@ version: '3' services: - devstack: - build: . + controller: + container_name: controller + hostname: controller + build: + context: . + dockerfile: controller/Dockerfile privileged: true tty: true + networks: + management_network: + ipv4_address: 172.28.0.2 + compute-1: + container_name: compute-1 + hostname: compute-1 + build: + context: . + dockerfile: compute/Dockerfile + privileged: true + tty: true + networks: + management_network: + ipv4_address: 172.28.0.3 + compute-2: + container_name: compute-2 + hostname: compute-2 + build: + context: . + dockerfile: compute/Dockerfile + privileged: true + tty: true + networks: + management_network: + ipv4_address: 172.28.0.4 +networks: + management_network: + driver: bridge + ipam: + driver: default + config: + - subnet: 172.28.0.0/24