Skip to content

Commit

Permalink
Add deployment of nginx webserver with pulp snippets
Browse files Browse the repository at this point in the history
* Build pulpweb container.

fixes #5657
https://pulp.plan.io/issues/5657
  • Loading branch information
chambridge committed Mar 1, 2021
1 parent b078c66 commit 1ecf4cf
Show file tree
Hide file tree
Showing 29 changed files with 487 additions and 58 deletions.
9 changes: 8 additions & 1 deletion .ci/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/bin/bash -e
#!/usr/bin/env bash

KUBE_FLAG=""
if
[ "$1" = "--minikube" ] || [ "$1" = "-m" ]; then
KUBE_FLAG="-m"
fi


echo "Build pulp/pulpcore images"
cd $GITHUB_WORKSPACE/containers/
cp $GITHUB_WORKSPACE/.ci/ansible/vars.yaml vars/vars.yaml
Expand All @@ -11,7 +18,7 @@ cd $GITHUB_WORKSPACE

echo "Test pulp/pulpcore images"
sudo -E ./up.sh
.ci/scripts/pulp-operator-check-and-wait.sh
.ci/scripts/pulp-operator-check-and-wait.sh $KUBE_FLAG
.ci/scripts/pulp_file-tests.sh

docker images
Expand Down
42 changes: 32 additions & 10 deletions .ci/scripts/pulp-operator-check-and-wait.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,25 @@
# 2. Wait for pulp-operator to be deployed to the point that pulp-api is able to
# serve requests.
#
# Currently only tested with k3s rather than a full K8s implementation.
# Currently only tested with k3s & minikube rather than a full K8s implementation.
# Uses generic K8s logic though.

KUBE="k3s"
if [[ "$1" == "--minikube" ]] || [[ "$1" == "-m" ]]; then
KUBE="minikube"
echo "Running $KUBE"
sleep 30
fi

storage_debug() {
echo "VOLUMES:"
sudo $KUBECTL get pvc
sudo $KUBECTL get pv
df -h
sudo $KUBECTL -n local-path-storage get pod
sudo $KUBECTL -n local-path-storage logs $STORAGE_POD
if [ "$KUBE" = "k3s" ]; then
sudo $KUBECTL -n local-path-storage get pod
sudo $KUBECTL -n local-path-storage logs $STORAGE_POD
fi
}

# CentOS 7 /etc/sudoers does not include /usr/local/bin
Expand All @@ -40,17 +49,18 @@ fi
# Once the services are both up, the pods will be in a Pending state.
# Before the services are both up, the pods may not exist at all.
# So check for the services being up 1st.
for tries in {0..30}; do
for tries in {0..90}; do
services=$(sudo $KUBECTL get services)
if [[ $(echo "$services" | grep -c NodePort) -eq 2 ]]; then
if [[ $(echo "$services" | grep -c NodePort) > 1 ]]; then
# parse string like this. 30805 is the external port
# pulp-api NodePort 10.43.170.79 <none> 24817:30805/TCP 0s
# pulp-api-svc NodePort 10.43.170.79 <none> 24817:30805/TCP 0s
API_PORT=$( echo "$services" | awk -F '[ :/]+' '/pulp-api/{print $6}')
SVC_NAME=$( echo "$services" | awk -F '[ :/]+' '/pulp-api/{print $1}')
echo "SERVICES:"
echo "$services"
break
else
if [[ $tries -eq 30 ]]; then
if [[ $tries -eq 90 ]]; then
echo "ERROR 2: 1 or more external services never came up"
echo "NAMESPACES:"
sudo $KUBECTL get namespaces
Expand All @@ -69,9 +79,11 @@ for tries in {0..30}; do
sleep 5
done

# This needs to be down here. Otherwise, the storage pod may not be
# up in time.
STORAGE_POD=$(sudo $KUBECTL -n local-path-storage get pod | awk '/local-path-provisioner/{print $1}')
if [[ "$KUBE" == "k3s" ]]; then
# This needs to be down here. Otherwise, the storage pod may not be
# up in time.
STORAGE_POD=$(sudo $KUBECTL -n local-path-storage get pod | awk '/local-path-provisioner/{print $1}')
fi

# NOTE: Before the pods can be started, they must be downloaded/cached from
# quay.io .
Expand Down Expand Up @@ -104,6 +116,12 @@ for tries in {0..180}; do
sleep 5
done

if [[ "$KUBE" == "minikube" ]]; then
API_NODE="localhost"
kubectl port-forward service/$SVC_NAME $API_PORT:$API_PORT &
sleep 60
fi

# Later tests in other scripts will use localhost:24817, which was not a safe
# assumption at the time this script was originally written.
URL=http://$API_NODE:$API_PORT/pulp/api/v3/status/
Expand Down Expand Up @@ -139,6 +157,10 @@ for tries in {0..120}; do
sleep 5
elif echo "$output" | grep "Request timed out" ; then
continue
elif echo "$output" | grep "HTTP/1.1 200 OK" ; then
echo "Successfully got the status page after _roughly_ $((tries * 5)) seconds"
echo "$output"
break
elif [[ $rc ]] ; then
echo "Successfully got the status page after _roughly_ $((tries * 5)) seconds"
echo "$output"
Expand Down
12 changes: 10 additions & 2 deletions .ci/scripts/pulp_file-tests.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
#!/usr/bin/env bash
# coding=utf-8

KUBE="k3s"
SERVER=$(hostname)
if [[ "$1" == "--minikube" ]] || [[ "$1" == "-m" ]]; then
KUBE="minikube"
SERVER="localhost"

fi

# From the pulp-server/pulp-api config-map
echo "machine $(hostname)
echo "machine $SERVER
login admin
password password\
" > ~/.netrc

export BASE_ADDR="http://$(hostname):24817"
export BASE_ADDR="http://$SERVER:24817"

pushd pulp_file/docs/_scripts
# Let's only do sync tests.
Expand Down
70 changes: 54 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,35 @@ jobs:
sudo -E apt-get -yq --no-install-suggests --no-install-recommends install httpie
echo ::endgroup::
echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/.ci/assets/httpie/" >> $GITHUB_ENV
echo "KUBECONFIG=/etc/rancher/k3s/k3s.yaml" >> $GITHUB_ENV
echo "IMG=quay.io/pulp/pulp-operator:latest" >> $GITHUB_ENV
echo "CI_TEST=true" >> $GITHUB_ENV
shell: bash
- name: Install minikube
id: minikube
uses: CodingNagger/minikube-setup-action@v1.0.2
with:
minikube-version: '1.17.1'
k8s-version: '1.20.2'
- name: Start minikube
run: |
minikube start --vm-driver=docker --extra-config=apiserver.service-node-port-range=80-32000
- name: Try the cluster !
run: kubectl get pods -A
- name: Setup a minikube docker env
run: minikube -p minikube docker-env | grep "export" | awk '{$1= ""; print $0}' >> $GITHUB_ENV
- name: Build Operator
run: |
echo ::group::SDK
CURRENT_VERSION=$(head -1 ./build/Dockerfile | cut -d ":" -f 2)
sudo wget https://github.com/operator-framework/operator-sdk/releases/download/$CURRENT_VERSION/operator-sdk-$CURRENT_VERSION-x86_64-linux-gnu -O /usr/local/bin/operator-sdk
sudo chmod +x /usr/local/bin/operator-sdk
echo ::endgroup::
sudo operator-sdk build quay.io/pulp/pulp-operator:latest
sudo docker images
eval $(minikube -p minikube docker-env)
sudo -E operator-sdk build quay.io/pulp/pulp-operator:latest
sudo -E docker images
shell: bash
- name: Test insta-demo
run: sudo -E insta-demo/pulp-insta-demo.sh
run: sudo -E insta-demo/pulp-insta-demo.sh -m
shell: bash
- name: After failure
if: failure()
Expand All @@ -55,6 +68,7 @@ jobs:
sudo kubectl logs -l app=pulp-content --tail=10000
sudo kubectl logs -l app=pulp-worker --tail=10000
sudo kubectl logs -l app=pulp-resource-manager --tail=10000
sudo kubectl logs -l app=pulp-web --tail=10000
http --timeout 30 --check-status --pretty format --print hb http://localhost:24817/pulp/api/v3/status/
components:
Expand All @@ -79,25 +93,36 @@ jobs:
echo "IMG=quay.io/pulp/pulp-operator:latest" >> $GITHUB_ENV
echo "CI_TEST=true" >> $GITHUB_ENV
shell: bash
- name: Install k3s
- name: Install minikube
id: minikube
uses: CodingNagger/minikube-setup-action@v1.0.2
with:
minikube-version: '1.17.1'
k8s-version: '1.20.2'
- name: Start minikube
run: |
sudo -E .ci/scripts/k3s-install.sh
shell: bash
minikube start --vm-driver=docker --extra-config=apiserver.service-node-port-range=80-32000
# now you can run kubectl to see the pods in the cluster
- name: Try the cluster !
run: kubectl get pods -A
- name: Setup a minikube docker env
run: minikube -p minikube docker-env | grep "export" | awk '{$1= ""; print $0}' >> $GITHUB_ENV
- name: Build Operator
run: |
echo ::group::SDK
CURRENT_VERSION=$(head -1 ./build/Dockerfile | cut -d ":" -f 2)
sudo wget https://github.com/operator-framework/operator-sdk/releases/download/$CURRENT_VERSION/operator-sdk-$CURRENT_VERSION-x86_64-linux-gnu -O /usr/local/bin/operator-sdk
sudo chmod +x /usr/local/bin/operator-sdk
echo ::endgroup::
sudo operator-sdk build quay.io/pulp/pulp-operator:latest
sudo docker images
eval $(minikube -p minikube docker-env)
sudo -E operator-sdk build quay.io/pulp/pulp-operator:latest
sudo -E docker images
shell: bash
- name: Deploy pulp-operator to K8s
run: sudo -E ./up.sh
shell: bash
- name: Check and wait pulp-operator deploy
run: .ci/scripts/pulp-operator-check-and-wait.sh
run: .ci/scripts/pulp-operator-check-and-wait.sh -m
shell: bash
- name: Test all components
run: |
Expand All @@ -115,6 +140,7 @@ jobs:
sudo kubectl logs -l app=pulp-content --tail=10000
sudo kubectl logs -l app=pulp-worker --tail=10000
sudo kubectl logs -l app=pulp-resource-manager --tail=10000
sudo kubectl logs -l app=pulp-web --tail=10000
http --timeout 30 --check-status --pretty format --print hb http://localhost:24817/pulp/api/v3/status/
molecule:
Expand All @@ -140,7 +166,7 @@ jobs:
echo "CI_TEST=true" >> $GITHUB_ENV
shell: bash
- name: Install
run: pip3 install molecule[docker,lint] openshift jmespath
run: pip3 install molecule[docker,lint] openshift=0.11.0 jmespath
- name: Molecule
run: .ci/scripts/molecule.sh
shell: bash
Expand Down Expand Up @@ -175,19 +201,30 @@ jobs:
echo "IMG=quay.io/pulp/pulp-operator:latest" >> $GITHUB_ENV
echo "CI_TEST=true" >> $GITHUB_ENV
shell: bash
- name: Install k3s
- name: Install minikube
id: minikube
uses: CodingNagger/minikube-setup-action@v1.0.2
with:
minikube-version: '1.17.1'
k8s-version: '1.20.2'
- name: Start minikube
run: |
sudo -E .ci/scripts/k3s-install.sh
shell: bash
minikube start --vm-driver=docker --extra-config=apiserver.service-node-port-range=80-32000
# now you can run kubectl to see the pods in the cluster
- name: Try the cluster !
run: kubectl get pods -A
- name: Setup a minikube docker env
run: minikube -p minikube docker-env | grep "export" | awk '{$1= ""; print $0}' >> $GITHUB_ENV
- name: Build Operator
run: |
echo ::group::SDK
CURRENT_VERSION=$(head -1 ./build/Dockerfile | cut -d ":" -f 2)
sudo wget https://github.com/operator-framework/operator-sdk/releases/download/$CURRENT_VERSION/operator-sdk-$CURRENT_VERSION-x86_64-linux-gnu -O /usr/local/bin/operator-sdk
sudo chmod +x /usr/local/bin/operator-sdk
echo ::endgroup::
sudo operator-sdk build quay.io/pulp/pulp-operator:latest
sudo docker images
eval $(minikube -p minikube docker-env)
sudo -E operator-sdk build quay.io/pulp/pulp-operator:latest
sudo -E docker images
shell: bash
- name: Setting secrets
run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT"
Expand All @@ -210,4 +247,5 @@ jobs:
sudo kubectl logs -l app=pulp-content --tail=10000
sudo kubectl logs -l app=pulp-worker --tail=10000
sudo kubectl logs -l app=pulp-resource-manager --tail=10000
sudo kubectl logs -l app=pulp-web --tail=10000
http --timeout 30 --check-status --pretty format --print hb http://localhost:24817/pulp/api/v3/status/
Loading

0 comments on commit 1ecf4cf

Please sign in to comment.