Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

techdebt: fix Makefile deploy #250

Merged
merged 11 commits into from
Jun 30, 2017
Merged

techdebt: fix Makefile deploy #250

merged 11 commits into from
Jun 30, 2017

Conversation

jmrodri
Copy link
Contributor

@jmrodri jmrodri commented Jun 30, 2017

No description provided.

@jmrodri
Copy link
Contributor Author

jmrodri commented Jun 30, 2017

TEST

Here are the steps you'll want to run. I will follow up with a comment that show expected output.

  • build the image you want to deploy
    make build-image ORG=jmrodri TAG=deployz
  • push the image you want to deploy
    docker push docker.io/jmrodri/ansible-service-broker:deployz
  • run make deploy with same args as make build-image
    make deploy ORG=jmrodri TAG=deployz

Now that you have the broker running, let's verify things are ok:

  • see if the broker project exists
    oc get project ansible-service-broker
  • see if the proper pods are there
    oc get pods
  • see the logs from the broker
    oc logs asb-661947336-mcgxl
  • try a simple request to bootstrap the broker
    curl -X POST asb-1338-ansible-service-broker.172.17.0.1.nip.io/v2/bootstrap

@jmrodri
Copy link
Contributor Author

jmrodri commented Jun 30, 2017

Actual output

MAKE BUILD-IMAGE

$ make build-image ORG=jmrodri TAG=deployz
cp broker build/broker
docker build -f "/home/jesusr/dev/src/github.com/openshift/ansible-service-broker/build"/Dockerfile-src -t docker.io/jmrodri/ansible-service-broker:deployz "/home/jesusr/dev/src/github.com/openshift/ansible-service-broker/build"
Sending build context to Docker daemon 34.67 MB
Step 1/13 : FROM centos:7
 ---> 3bee3060bfc8
Step 2/13 : MAINTAINER Ansible Service Broker Community
 ---> Using cache
 ---> 3e9ab6f83023
Step 3/13 : ENV USER_NAME ansibleservicebroker USER_UID 1001 BASE_DIR /opt/ansibleservicebroker
 ---> Using cache
 ---> ef552e227718
Step 4/13 : ENV HOME ${BASE_DIR}
 ---> Using cache
 ---> 9423747ba8aa
Step 5/13 : RUN mkdir -p ${BASE_DIR} ${BASE_DIR}/etc  && useradd -u ${USER_UID} -r -g 0 -M -d ${BASE_DIR} -b ${BASE_DIR} -s /sbin/nologin -c "ansibleservicebroker user" ${USER_NAME}  && chown -R ${USER_NAME}:0 ${BASE_DIR}  && chmod -R g+rw ${BASE_DIR} /etc/passwd
 ---> Using cache
 ---> 2e5910b3e26f
Step 6/13 : RUN yum -y update  && yum -y install epel-release centos-release-openshift-origin  && yum -y install origin-clients net-tools bind-utils  && yum clean all
 ---> Using cache
 ---> 00007d92a3ba
Step 7/13 : RUN mkdir /var/log/ansible-service-broker     && touch /var/log/ansible-service-broker/asb.log     && mkdir /etc/ansible-service-broker
 ---> Using cache
 ---> 7bad9816f180
Step 8/13 : COPY entrypoint.sh /usr/bin/
 ---> Using cache
 ---> 1f17edd8e173
Step 9/13 : COPY broker /usr/bin/asbd
 ---> Using cache
 ---> 5b208902f690
Step 10/13 : RUN chown -R ${USER_NAME}:0 /var/log/ansible-service-broker  && chown -R ${USER_NAME}:0 /etc/ansible-service-broker  && chmod -R g+rw /var/log/ansible-service-broker /etc/ansible-service-broker
 ---> Using cache
 ---> d8f6dda39173
Step 11/13 : USER ${USER_UID}
 ---> Using cache
 ---> 6fe86e0b6979
Step 12/13 : RUN sed "s@${USER_NAME}:x:${USER_UID}:@${USER_NAME}:x:\${USER_ID}:@g" /etc/passwd > ${BASE_DIR}/etc/passwd.template
 ---> Using cache
 ---> f6545b0b6e74
Step 13/13 : ENTRYPOINT entrypoint.sh
 ---> Using cache
 ---> eb16a39c2792
Successfully built eb16a39c2792

Remember you need to push your image before calling make deploy
    docker push docker.io/jmrodri/ansible-service-broker:deployz

DOCKER PUSH

$ docker push docker.io/jmrodri/ansible-service-broker:deployz
The push refers to a repository [docker.io/jmrodri/ansible-service-broker]
e88a1869b5c2: Layer already exists 
d3e0dd1c729a: Layer already exists 
01d818cb53b0: Layer already exists 
9047eb4c0212: Layer already exists 
638d205de2bd: Layer already exists 
6c65a435a8ee: Layer already exists 
b35c650dc11f: Layer already exists 
dc1e2dcdc7b6: Layer already exists 
deployz: digest: sha256:ad1b23f133a26bd29c293502a4eb26b33395c6e2d8cfd9b53fbac8812cc1e570 size: 1988

MAKE DEPLOY

$ make deploy ORG=jmrodri TAG=deployz
project "ansible-service-broker" deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
clusterrolebinding "asb" deleted
Already on project "ansible-service-broker" on server "https://172.17.0.1:8443".

You can add applications to this project with the 'new-app' command. For example, try:

    oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git

to build a new example application in Ruby.
service "asb" created
service "etcd" created
serviceaccount "asb" created
clusterrolebinding "asb" created
route "asb-1338" created
persistentvolumeclaim "etcd" created
deployment "asb" created
deployment "etcd" created
configmap "broker-config" created

OC GET PROJECT

$ oc get project ansible-service-broker
NAME                     DISPLAY NAME   STATUS
ansible-service-broker                  Active

OC GET PODS

$ oc get pods
NAME                    READY     STATUS    RESTARTS   AGE
asb-661947336-mcgxl     1/1       Running   1          1m
etcd-2338997634-kpmg0   1/1       Running   0          1m

OC LOGS ASB

$ oc logs asb-661947336-mcgxl 
Using config file mounted to /etc/ansible-service-broker/config.yaml
============================================================
==           Starting Ansible Service Broker...           ==
============================================================
[2017-06-30T15:07:06.842Z] [NOTICE] Initializing clients...
[2017-06-30T15:07:06.842Z] [DEBUG] Trying to connect to etcd
[2017-06-30T15:07:06.842Z] [INFO] == ETCD CX ==
[2017-06-30T15:07:06.842Z] [INFO] EtcdHost: etcd
[2017-06-30T15:07:06.842Z] [INFO] EtcdPort: 2379
[2017-06-30T15:07:06.842Z] [INFO] Endpoints: [http://etcd:2379]
[2017-06-30T15:07:06.844Z] [INFO] Etcd Version [Server: 3.2.1, Cluster: 3.2.0]
[2017-06-30T15:07:06.844Z] [DEBUG] Connecting to Cluster
[2017-06-30T15:07:06.845Z] [DEBUG] Connecting Dao
[2017-06-30T15:07:06.872Z] [INFO] Kubernetes version: v1.6.1+5115d708d7
[2017-06-30T15:07:06.872Z] [DEBUG] Connecting Registry
[2017-06-30T15:07:06.872Z] [INFO] == REGISTRY CX == 
[2017-06-30T15:07:06.872Z] [INFO] Name: dockerhub
[2017-06-30T15:07:06.872Z] [INFO] Url: docker.io
[2017-06-30T15:07:06.872Z] [DEBUG] DockerHubRegistry::Init
[2017-06-30T15:07:06.872Z] [DEBUG] Initializing WorkEngine
[2017-06-30T15:07:06.872Z] [DEBUG] Initializing Provision WorkSubscriber
[2017-06-30T15:07:06.872Z] [DEBUG] Creating AnsibleBroker
[2017-06-30T15:07:06.872Z] [INFO] Listening for provision messages
[2017-06-30T15:07:06.872Z] [DEBUG] Logging into openshift...
[2017-06-30T15:07:07.134Z] [INFO] Initiating Recovery Process
[2017-06-30T15:07:07.134Z] [DEBUG] Dao::FindByState
[2017-06-30T15:07:07.135Z] [INFO] No jobs to recover
[2017-06-30T15:07:07.135Z] [NOTICE] 
[2017-06-30T15:07:07.135Z] [NOTICE] Ansible Service Broker Started
[2017-06-30T15:07:07.135Z] [NOTICE] Listening on http://0.0.0.0:1338

BOOTSTRAP

$ curl -X POST asb-1338-ansible-service-broker.172.17.0.1.nip.io/v2/bootstrap
{
  "spec_count": 1,
  "image_count": 2
}

@jmrodri
Copy link
Contributor Author

jmrodri commented Jun 30, 2017

You can also deploy the image from ansibleplaybookbundle organization. This can be useful to test between your current image changes and the previously released version.

$ make deploy 
project "ansible-service-broker" deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
clusterrolebinding "asb" deleted
Already on project "ansible-service-broker" on server "https://172.17.0.1:8443".

You can add applications to this project with the 'new-app' command. For example, try:

    oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git

to build a new example application in Ruby.
service "asb" created
service "etcd" created
serviceaccount "asb" created
clusterrolebinding "asb" created
route "asb-1338" created
persistentvolumeclaim "etcd" created
deployment "asb" created
deployment "etcd" created
configmap "broker-config" created

@jmrodri
Copy link
Contributor Author

jmrodri commented Jun 30, 2017

WARNING:

be careful with the docker push especially if you forget to pass in PROJECT to the build-image target.

# override with from my_local_dev_vars
PROJECT="ansible-service-broker"
OPENSHIFT_TARGET="https://kubernetes.default"
OPENSHIFT_USER="admin"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably remove OPENSHIFT_USER and OPENSHIFT_PASS since they are no longer being used.

The template also needs to remove these, but that might be a different PR when we expose the path for token, target, and ca_file.

validate_var "DOCKERHUB_ORG" $DOCKERHUB_ORG

# configure variables to pass to template
VARS="-p BROKER_IMAGE=${BROKER_IMAGE} -p OPENSHIFT_TARGET=${OPENSHIFT_TARGET} -p OPENSHIFT_PASS=${OPENSHIFT_PASS} -p OPENSHIFT_USER=${OPENSHIFT_USER} -p DOCKERHUB_ORG=${DOCKERHUB_ORG} -p DOCKERHUB_PASS=${DOCKERHUB_PASS} -p DOCKERHUB_USER=${DOCKERHUB_USER} -p REGISTRY_TYPE=${REGISTRY_TYPE} -p REGISTRY_URL=${REGISTRY} -p DEV_BROKER=${DEV_BROKER} -p LAUNCH_APB_ON_BIND=${LAUNCH_APB_ON_BIND} -p OUTPUT_REQUEST=${OUTPUT_REQUEST} -p RECOVERY=${RECOVERY}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with remove OPENSHIFT_USER and OPENSHIFT_PASS

@jwmatthews
Copy link
Member

LGTM

Minor comment on OPENSHIFT_USER/PASS, since they aren't used by the broker, lets remove them from the deploy script.

Copy link
Contributor

@eriknelson eriknelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. Ran through the tests, all looking good. Just needs the update from PROJECT -> ORG.

@jmrodri
Copy link
Contributor Author

jmrodri commented Jun 30, 2017

result after PROJECT -> ORG

[jesusr@speed3 ansible-service-broker{makefile-deploy}]$ make deploy ORG=jmrodri TAG=orgnotproject
project "ansible-service-broker" deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
  * ansible-service-broker
Using project "ansible-service-broker" on server "https://172.17.0.1:8443".
Waiting for ansible-service-broker to be deleted
clusterrolebinding "asb" deleted
Already on project "ansible-service-broker" on server "https://172.17.0.1:8443".

You can add applications to this project with the 'new-app' command. For example, try:

    oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git

to build a new example application in Ruby.
service "asb" created
service "etcd" created
serviceaccount "asb" created
clusterrolebinding "asb" created
route "asb-1338" created
persistentvolumeclaim "etcd" created
deployment "asb" created
deployment "etcd" created
configmap "broker-config" created
[jesusr@speed3 ansible-service-broker{makefile-deploy}]$ oc get projects
NAME                     DISPLAY NAME   STATUS
ansible-service-broker                  Active
default                                 Active
kube-public                             Active
kube-system                             Active
myproject                My Project     Active
openshift                               Active
openshift-infra                         Active
service-catalog                         Active
[jesusr@speed3 ansible-service-broker{makefile-deploy}]$ oc project ansible-service-broker
Already on project "ansible-service-broker" on server "https://172.17.0.1:8443".
[jesusr@speed3 ansible-service-broker{makefile-deploy}]$ curl -X POST asb-1338-ansible-service-broker.172.17.0.1.nip.io/v2/bootstrap
{
  "spec_count": 1,
  "image_count": 2
}

@eriknelson
Copy link
Contributor

ACK following PROJECT -> ORG, same behavior. Merging.

@eriknelson eriknelson merged commit f05b5d7 into master Jun 30, 2017
@eriknelson eriknelson deleted the makefile-deploy branch June 30, 2017 17:20
@jmrodri
Copy link
Contributor Author

jmrodri commented Jun 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants