{"id":1295,"date":"2016-01-15T18:45:43","date_gmt":"2016-01-15T23:45:43","guid":{"rendered":"http:\/\/blog.domb.net\/?p=1295"},"modified":"2016-09-16T16:34:47","modified_gmt":"2016-09-16T20:34:47","slug":"container-metrics-and-introspection-with-cloudforms-4-0-and-openshift-3-1","status":"publish","type":"post","link":"https:\/\/blog.domb.net\/?p=1295","title":{"rendered":"Container Metrics And Introspection With CloudForms 4.0 And OpenShift 3.1 &#8211; Updated for OpenShift 3.2 and CF 4.1"},"content":{"rendered":"<p>If you were wondering how CloudForms 4.0 and OpenShift 3.1 work together then you are at the right place. This post is about the integration of CloudForms 4.0 and OpenShift 3.1. I will describe how-to install OSE 3.1 and how-to configure it so that you can connect CloudForms with OpenShift 3.1. My steps here are for a small POC and by no means production. The goal is that CloudForms will discover the OpenShift environment and collect metrics of the containers as well as package information through smart state analysis\/introspection. For introspection to work properly you CloudForms appliance needs to have the smart-proxy role enabled.<\/p>\n<p>I wrote 2 scripts which do the whole work for you. If everything works fine you should be able to do the same as I show in the following video<\/p>\n<p><iframe loading=\"lazy\" title=\"Container \/ Docker Metrics And Introspection With CloudForms 4.0 And OpenShift 3.1\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/o5wySR67IiM?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p>If you don&#8217;t wont to do this step by step here is the github repo to it.<\/p>\n<p><a href=\"https:\/\/github.com\/ldomb\/buildoseforcfme\">https:\/\/github.com\/ldomb\/buildoseforcfme<\/a><\/p>\n<p>Step 1. This will prepare the master and nodes for the ose install.<\/p>\n<pre class=\"lang:sh decode:true \" title=\"Prepares OSE hosts for OpenShift\">[root@masterallinone ~]# cat &gt; \/root\/prepforeose.sh &lt;&lt;EOFPREP\r\nMASTERFQDN=master.local.domb.com\r\n#NODE1FQDN=node1.local.domb.com\r\n#NODE2FQDN=node2.local.domb.com\r\n#NODE3FQDN=node3.local.domb.com\r\nRHNUSER=youruser\r\nRHNPASSWORD=yourpass\r\nPOOLID=yourpool\r\n\r\necho \"Registering System\"\r\nsubscription-manager register --username=$RHNUSER --password=$RHNPASSWORD\r\nsubscription-manager attach --pool=$POOLID\r\n\r\necho \"enabling all the repos\"\r\nsubscription-manager repos --disable=\"*\"\r\nsubscription-manager repos \\\r\n    --enable=\"rhel-7-server-rpms\" \\\r\n    --enable=\"rhel-7-server-extras-rpms\" \\\r\n    --enable=\"rhel-7-server-ose-3.2-rpms\"\r\n\r\nyum -y install wget git net-tools bind-utils iptables-services bridge-utils bash-completion httpd-tools\r\n\r\nyum update -y\r\n### Install utilites for quick and advanced installation\"\r\nyum -y install atomic-openshift-utils\r\n\r\nyum install -y docker-1.10.3\r\nmkdir \/images\r\nchmod a+rwx \/images\r\n\r\nsed -i 's|--selinux-enabled|--insecure-registry=172.30.0.0\/16 --selinux-enabled|g' \/etc\/sysconfig\/docker\r\n\r\nif [ \"`hostname -f`\" == \"$MASTERFQDN\" ];\r\nthen\r\nssh-keygen\r\n  if [ -n \"${MASTERFQDN}\" ]; then\r\n    echo \"Copying keys to $MASTERFQDN\"\r\n    ssh-keygen\r\n    ssh-copy-id root@$MASTERFQDN\r\n  fi\r\n\r\n  if [ -n \"${NODE1FQDN}\" ]; then\r\n    echo \"Copying keys to $NODE1FQDN\"\r\n    ssh-copy-id root@$NODE1FQDN\r\n    scp \/root\/prepforeose.sh root@$NODE1FQDN:\r\n    ssh root@$NODE1FQDN \"chmod +x \/root\/prepforeose.sh &amp;&amp; .\/prepforeose.sh\"\r\n    ssh root@$NODE1FQDN \"init 6\"\r\n  fi\r\n\r\n  if [ -n \"${NODE2FQDN}\" ]; then\r\n    echo \"Copying keys to $NODE2FQDN\"\r\n    ssh-copy-id root@$NODE2FQDN\r\n    scp \/root\/prepforeose.sh root@$NODE2FQDN:\r\n    ssh root@$NODE2FQDN \"chmod +x \/root\/prepforeose.sh &amp;&amp; .\/prepforeose.sh\"\r\n    ssh root@$NODE2FQDN \"init 6\"\r\n  fi\r\n\r\n  if [ -n \"${NODE3FQDN}\" ]; then\r\n    echo \"Copying keys to $NODE3FQDN\"\r\n    ssh-copy-id root@$NODE3FQDN\r\n    scp \/root\/prepforeose.sh root@$NODE3FQDN:\r\n    ssh root@$NODE3FQDN \"chmod +x \/root\/prepforeose.sh &amp;&amp; .\/prepforeose.sh\"\r\n    ssh root@$NODE3FQDN \"init 6\"\r\n  fi\r\nfi\r\n\r\necho \"reboot master manually\"\r\nEOFPREP\r\n<\/pre>\n<p>Step 2. Execute prepforeose.sh. You will have to enter the root password during ssh-copy-id.<\/p>\n<pre class=\"lang:sh decode:true \">[root@masterallinone ~]# chmod +x \/root\/prepforeose.sh &amp;&amp; \/root\/prepforeose.sh<\/pre>\n<p>Step 3. The buildoseforcfme.sh script runs ansible to install OSE v3 and creates all the user\/service accounts so that you can connect to OpenShift from CloudForms. <\/p>\n<pre class=\"lang:sh decode:true \" title=\"OSE v3.1 installer\">[root@masterallinone ~]# cat &gt; \/root\/buildoseforcfme.sh &lt;&lt;EOFOSE\r\n#!\/bin\/bash\r\n# Create an OSEv3 group that contains the masters and nodes groups\r\n\r\nMASTERFQDN='master.local.domb.com'\r\n#NODE1FQDN='node1.local.domb.com'\r\n#NODE2FQDN='node2.local.domb.com'\r\n#NODE3FQDN='node3.local.domb.com'\r\nSUBDOMAIN='apps.local.domb.com'\r\nHAWKULARFQDN=$MASTERFQDN\r\nUSER1=admin\r\nUSER2=''\r\n######################################################################\r\n\r\ncd ~\r\n\r\necho \"Writing Ansible HOSTS File\"\r\ncat &lt;&lt;EOF | tee \/etc\/ansible\/hosts\r\n[OSEv3:children]\r\nmasters\r\nnodes\r\n\r\n# Set variables common for all OSEv3 hosts\r\n[OSEv3:vars]\r\n# SSH user, this user should allow ssh based auth without requiring a password\r\nansible_ssh_user=root\r\nosm_default_subdomain=$SUBDOMAIN\r\n\r\n# If ansible_ssh_user is not root, ansible_sudo must be set to true\r\n#ansible_sudo=true\r\n\r\ndeployment_type=openshift-enterprise\r\n\r\n# uncomment the following to enable htpasswd authentication; defaults to DenyAllPasswordIdentityProvider\r\nopenshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '\/etc\/origin\/htpasswd'}]\r\n\r\n# host group for masters\r\n[masters]\r\n$MASTERFQDN\r\n\r\n# host group for nodes, includes region info\r\n[nodes]\r\n$MASTERFQDN openshift_node_labels=\"{'region': 'infra', 'zone': 'default'}\"\r\n#$NODE1FQDN openshift_node_labels=\"{'region': 'primary', 'zone': 'default'}\"\r\n#$NODE2FQDN openshift_node_labels=\"{'region': 'primary', 'zone': 'default'}\"\r\n#$NODE3FQDN openshift_node_labels=\"{'region': 'infra', 'zone': 'default'}\"\r\nEOF\r\n\r\necho \"Running Asible\"\r\nansible-playbook \/usr\/share\/ansible\/openshift-ansible\/playbooks\/byo\/config.yml\r\n\r\necho \"making master node schedulable\"\r\noadm manage-node $MASTERFQDN --schedulable=true\r\n\r\n\r\nif [ -n \"${USER1}\" ]; then\r\n    echo \"Creating user $USER1\"\r\n    htpasswd \/etc\/origin\/htpasswd $USER1\r\n    oadm policy add-cluster-role-to-user cluster-admin $USER1\r\nfi\r\n\r\nif [ -n \"${USER2}\" ]; then\r\n    echo \"Creating user $USER2\"\r\n    htpasswd \/etc\/origin\/htpasswd $USER2\r\nfi\r\n\r\necho \"login as admin\"\r\noc login -u system:admin\r\n\r\n###### Obsolete in OSE 3.2 is created by ansible #######\r\necho \"creating registery\"\r\n#oadm registry --service-account=registry --config=\/etc\/origin\/master\/admin.kubeconfig --credentials=\/etc\/origin\/master\/openshift-registry.kubeconfig --images='registry.access.redhat.com\/openshift3\/ose-${component}:${version}' --mount-host=\/images\r\necho \"creating cert\"\r\nCA=\/etc\/origin\/master\r\noadm ca create-server-cert --signer-cert=$CA\/ca.crt --signer-key=$CA\/ca.key --signer-serial=$CA\/ca.serial.txt --hostnames='*.$SUBDOMAIN' --cert=cloudapps.crt --key=cloudapps.key\r\ncat cloudapps.crt cloudapps.key $CA\/ca.crt &gt; cloudapps.router.pem\r\n\r\necho \"Adding router\"\r\n#oadm router --default-cert=cloudapps.router.pem --credentials='\/etc\/origin\/master\/openshift-router.kubeconfig' --selector='region=infra' --images='registry.access.redhat.com\/openshift3\/ose-${component}:${version}' --service-account router\r\n####################################\r\n\r\noc project management-infra\r\noadm policy add-role-to-user -n management-infra admin -z management-admin\r\noadm policy add-role-to-user -n management-infra management-infra-admin -z management-admin\r\noadm policy add-cluster-role-to-user cluster-reader system:serviceaccount:management-infra:management-admin\r\noadm policy add-scc-to-user privileged system:serviceaccount:management-infra:management-admin\r\noc sa get-token -n management-infra management-admin &gt; \/root\/cfme4token.txt\r\n\r\necho \"Createing Metrics\"\r\noc project openshift-infra\r\noc create -f - &lt;&lt;API\r\napiVersion: v1\r\nkind: ServiceAccount\r\nmetadata:\r\n  name: metrics-deployer\r\nsecrets:\r\n- name: metrics-deployer\r\nAPI\r\n\r\noadm policy add-role-to-user \\\r\n    edit system:serviceaccount:openshift-infra:metrics-deployer\r\n\r\noadm policy add-cluster-role-to-user \\\r\n    cluster-reader system:serviceaccount:openshift-infra:heapster\r\n\r\noc secrets new metrics-deployer nothing=\/dev\/null\r\ncp \/usr\/share\/openshift\/examples\/infrastructure-templates\/enterprise\/metrics-deployer.yaml metrics-deployer.yaml\r\noc new-app -f metrics-deployer.yaml \\\r\n    -p HAWKULAR_METRICS_HOSTNAME=hawkular-metrics.$SUBDOMAIN \\\r\n    -p USE_PERSISTENT_STORAGE=false\r\n    -p METRIC_DURATION=7\r\n\r\n\r\n############## Not needed for CF 4.1 and OSE 3.2 ######################################################\r\necho \"creating router for managmeent metrics\"\r\n#### This router must, at the moment, run on the master nodes to expose the metrics on the port 5000 to CloudForms Management Engine, hence the need for a selector on the kubernetes.io\/hostname of the master node. ####\r\n\r\noadm router management-metrics -n default --credentials=\/etc\/origin\/master\/openshift-router.kubeconfig --service-account=router --ports='443:5000' --selector=\"kubernetes.io\/hostname=$MASTERFQDN\" --stats-port=1937 --host-network=false\r\n\r\n#######################################################################################################\r\n\r\necho \"MAUNUAL SETPS\"\r\necho \"add line to \/etc\/origin\/master\/master-config.yaml\"\r\necho \"assetConfig:\"\r\necho \"metricsPublicURL: https:\/\/$MASTERFQDN\/hawkular\/metrics\"\r\nEOFOSE\r\n<\/pre>\n<p>Step 4. Execute the buildoseforcfme.sh script. Make sure to visit the hawkular URL in the browser and accept the cert for https:\/\/$HAWKULARFQDN\/hawkular\/metrics and https:\/\/$HAWKULARFQDN:5000 . After the install you will find the needed token for CloudForms in \/root\/cfme4token.txt. You can add it to your CloudForms OpenShift Provider.  <\/p>\n<pre class=\"lang:sh decode:true \">[root@masterallinone ~]# chmod +x \/root\/buildoseforcfme.sh &amp;&amp; \/root\/buildoseforcfme.sh<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-20-at-8.35.52-AM.png\" alt=\"Screen Shot 2016-07-20 at 8.35.52 AM\" width=\"1628\" height=\"652\" class=\"aligncenter size-full wp-image-1480\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-20-at-8.35.52-AM.png 1628w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-20-at-8.35.52-AM-300x120.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-20-at-8.35.52-AM-768x308.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-20-at-8.35.52-AM-1024x410.png 1024w\" sizes=\"auto, (max-width: 1628px) 100vw, 1628px\" \/><\/p>\n<p>Step 5. For Hawkular add the hawkular URL. If this is not your master like in this example you will have to point to the node where hawkular is running or in a HA setup to the load balancer which forwards the port 443.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-20-at-8.36.06-AM.png\" alt=\"Screen Shot 2016-07-20 at 8.36.06 AM\" width=\"1753\" height=\"569\" class=\"aligncenter size-full wp-image-1482\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-20-at-8.36.06-AM.png 1753w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-20-at-8.36.06-AM-300x97.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-20-at-8.36.06-AM-768x249.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-20-at-8.36.06-AM-1024x332.png 1024w\" sizes=\"auto, (max-width: 1753px) 100vw, 1753px\" \/><\/p>\n<p>Step 6. In CloudForms make sure that all the metrics collection check-boxes are enabled under Configure-&gt;Configuration-&gt;Server-Server Control.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-22-at-10.58.26-AM.png\" alt=\"Screen Shot 2016-07-22 at 10.58.26 AM\" width=\"1273\" height=\"726\" class=\"aligncenter size-full wp-image-1487\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-22-at-10.58.26-AM.png 1273w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-22-at-10.58.26-AM-300x171.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-22-at-10.58.26-AM-768x438.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2016-07-22-at-10.58.26-AM-1024x584.png 1024w\" sizes=\"auto, (max-width: 1273px) 100vw, 1273px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you were wondering how CloudForms 4.0 and OpenShift 3.1 work together then you are at the right place. This post is about the integration of CloudForms 4.0 and OpenShift 3.1. I will describe how-to install OSE 3.1 and how-to configure it so that you can connect CloudForms with OpenShift 3.1. My steps here are&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[37],"tags":[],"class_list":["post-1295","post","type-post","status-publish","format-standard","hentry","category-cloudforms"],"_links":{"self":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/1295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1295"}],"version-history":[{"count":65,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/1295\/revisions"}],"predecessor-version":[{"id":1521,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/1295\/revisions\/1521"}],"wp:attachment":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}