<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Randima Somathilaka on Medium]]></title>
        <description><![CDATA[Stories by Randima Somathilaka on Medium]]></description>
        <link>https://medium.com/@randima.somathilaka?source=rss-a7024b5aaf3a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zB6V1NvCmuHzJ-VaJW9sGw.jpeg</url>
            <title>Stories by Randima Somathilaka on Medium</title>
            <link>https://medium.com/@randima.somathilaka?source=rss-a7024b5aaf3a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 00:01:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@randima.somathilaka/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[WSO2 IS email OTP as 2nd factor for WSO2 AM management console login]]></title>
            <link>https://medium.com/@randima.somathilaka/wso2-is-email-otp-as-2nd-factor-for-wso2-am-management-console-login-8590404f1cf1?source=rss-a7024b5aaf3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8590404f1cf1</guid>
            <category><![CDATA[wso2am]]></category>
            <category><![CDATA[wso2is]]></category>
            <category><![CDATA[otp]]></category>
            <category><![CDATA[email]]></category>
            <category><![CDATA[aml]]></category>
            <dc:creator><![CDATA[Randima Somathilaka]]></dc:creator>
            <pubDate>Fri, 08 May 2020 12:02:18 GMT</pubDate>
            <atom:updated>2020-06-01T11:30:05.878Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*sBBpfZNX--FM7WUVPF4_Hg.png" /></figure><p>While configuring email OTP as 2nd-factor authentication for WSO2 AM management console login, I ran into some confusing outcomes. This guide will help to resolve any such issue in a WSO2 IS-KM-5.6.0 and WSO2-AM-2.5.0 setup.</p><p><strong>Note</strong>: This guide won’t cover any configuration related to setting up WSO2 IS-Km as the key-manager for WSO2 AM. The guide assumes that you already have a working key-manager setup, including WSO2-IS and WSO2-AM. And WSO2-IS-KM is running in <strong>9443</strong> port, and WSO2-AM is running in <strong>9444</strong> port.</p><p><strong>Step 1: Configuring WSO2-IS-KM as the email OTP provider</strong></p><ul><li>Uncomment and update the <strong>mailto</strong> transport sender in<strong>&lt;IS-KM_HOME&gt;/repository/conf/axis2/axis2.xml </strong>file with relevant details.</li></ul><pre>&lt;transportSender  name=&quot;mailto&quot; class=&quot;org.apache.axis2.transport.mail.MailTransportSender&quot;&gt;</pre><pre>&lt;parameter  name=&quot;mail.smtp.from&quot;&gt;<strong>username@gmail.com</strong>&lt;/parameter&gt;</pre><pre>&lt;parameter  name=&quot;mail.smtp.user&quot;&gt;<strong>username</strong>&lt;/parameter&gt;</pre><pre>&lt;parameter  name=&quot;mail.smtp.password&quot;&gt;<strong>password</strong>&lt;/parameter&gt;</pre><pre>&lt;parameter  name=&quot;mail.smtp.host&quot;&gt;smtp.gmail.com&lt;/parameter&gt;</pre><pre>&lt;parameter  name=&quot;mail.smtp.port&quot;&gt;587&lt;/parameter&gt;</pre><pre>&lt;parameter  name=&quot;mail.smtp.starttls.enable&quot;&gt;<strong>true</strong>&lt;/parameter&gt;</pre><pre>&lt;parameter  name=&quot;mail.smtp.auth&quot;&gt;<strong>true</strong>&lt;/parameter&gt;</pre><pre>&lt;/transportSender&gt;</pre><ul><li>Comment out the <strong>module</strong> property in the same file.</li></ul><pre>&lt;!-- &lt;module ref=&quot;addressing&quot;/&gt; --&gt;</pre><ul><li>Update the <strong>email</strong> adapter config in<strong>&lt;IS-KM_HOME&gt;/repository/conf/output-event-adapters.xml </strong>file with the same details (from, user, password details of sender’s Gmail account).</li><li>Add a new email template for email OTP in <strong>&lt;IS-KM_HOME&gt;/repository/conf/email/email-admin-config.xml </strong>file inside <strong>configurations</strong> tags. Make sure to keep display attribute value as <strong>EmaiOTP</strong> and locale attribute value as <strong>en_US</strong>.</li></ul><pre>&lt;<strong>configuration</strong> type=&quot;EmailOTP&quot; display=&quot;EmailOTP&quot; locale=&quot;en_US&quot; emailContentType=&quot;text/html&quot;&gt;</pre><pre>&lt;<strong>targetEpr</strong>&gt;&lt;/<strong>targetEpr</strong>&gt;</pre><pre>&lt;<strong>subject</strong>&gt;{YOUR_SUBJECT_CONTENT}&lt;/<strong>subject</strong>&gt;</pre><pre>&lt;<strong>body</strong>&gt;</pre><pre>Hi,</pre><pre>Please use this one time password {{OTPCode}} to sign in to your application.</pre><pre>&lt;/<strong>body</strong>&gt;</pre><pre>&lt;<strong>footer</strong>&gt;</pre><pre>{YOUR_FOOTER_CONTENT}</pre><pre>&lt;/<strong>footer</strong>&gt;</pre><pre>&lt;<strong>redirectPath</strong>&gt;&lt;/<strong>redirectPath</strong>&gt;</pre><pre>&lt;/<strong>configuration</strong>&gt;</pre><ul><li>Set values of below two properties to <strong>true </strong>in the <strong>&lt;IS-KM_HOME&gt;/repository/conf/identity/identity-mgt.properties </strong>file.</li></ul><pre>Authentication.Policy.Enable=true<br>Authentication.Policy.Check.OneTime.Password=true</pre><ul><li>Find and update the <strong>EmailOTP</strong> <strong>AuthenticatorConfig </strong>section in the <strong>&lt;IS_KM_HOME&gt;/repository/conf/identity/application-authentication.xml </strong>file with below configurations.</li></ul><pre>&lt;AuthenticatorConfig name=&quot;EmailOTP&quot; enabled=&quot;true&quot;&gt;</pre><pre>&lt;Parameter name=&quot;EMAILOTPAuthenticationEndpointURL&quot;&gt;https://localhost:9443/emailotpauthenticationendpoint/emailotp.jsp&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;EmailOTPAuthenticationEndpointErrorPage&quot;&gt;https://localhost:9443/emailotpauthenticationendpoint/emailotpError.jsp&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;EmailAddressRequestPage&quot;&gt;https://localhost:9443/emailotpauthenticationendpoint/emailAddress.jsp&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;usecase&quot;&gt;association&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;useEventHandlerBasedEmailSender&quot;&gt;<strong>true</strong>&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;secondaryUserstore&quot;&gt;primary&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;EMAILOTPMandatory&quot;&gt;<strong>false</strong>&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;sendOTPToFederatedEmailAttribute&quot;&gt;<strong>false</strong>&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;federatedEmailAttributeKey&quot;&gt;email&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;EmailOTPEnableByUserClaim&quot;&gt;<strong>true</strong>&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;useEventHandlerBasedEmailSender&quot;&gt;<strong>true</strong>&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;CaptureAndUpdateEmailAddress&quot;&gt;<strong>true</strong>&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;showEmailAddressInUI&quot;&gt;<strong>true</strong>&lt;/Parameter&gt;</pre><pre>&lt;/AuthenticatorConfig&gt;</pre><ul><li>Then start the WSO2-IS-KM server</li></ul><p><strong>Step 2: Configuring WSO2 AM management console for SSO</strong></p><ul><li>Update the <strong>SAML2SSOAuthenticator </strong>configurations with below values in <strong>&lt;AM_HOME&gt;/repository/conf/security/authenticators.xml </strong>file.</li></ul><ol><li>disabled: <strong>false</strong></li><li>ServiceProviderId: <strong>API-Manager-Carbon</strong></li><li>IdentityProviderSSOServiceURL: <a href="https://localhost:9443/samlsso"><strong>https://localhost:9443/samlsso</strong></a></li><li>AssertionConsumerServiceURL: <a href="https://localhost:9444/acs"><strong>https://localhost:9444/acs</strong></a></li></ol><pre>&lt;Authenticator name=&quot;SAML2SSOAuthenticator&quot; disabled=&quot;<strong>false</strong>&quot;&gt;</pre><pre>&lt;Priority&gt;10&lt;/Priority&gt;</pre><pre>&lt;Config&gt;</pre><pre>&lt;Parameter name=&quot;LoginPage&quot;&gt;/carbon/admin/login.jsp&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;ServiceProviderID&quot;&gt;<strong>API-Manager-Carbon</strong>&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;IdentityProviderSSOServiceURL&quot;&gt;<strong>https://localhost:9443/samlsso</strong>&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;NameIDPolicyFormat&quot;&gt;urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;AssertionConsumerServiceURL&quot;&gt;<strong>https://localhost:9444/acs</strong>&lt;/Parameter&gt;</pre><pre>&lt;Parameter name=&quot;AssertionSignatureValidationEnabled&quot;&gt;true&lt;/Parameter&gt;</pre><pre>&lt;/Config&gt;</pre><pre>&lt;/Authenticator&gt;</pre><ul><li>Then start the WSO2-AM server.</li></ul><p><strong>Step 3: Configuring EmailOTP IDP</strong></p><ul><li>Login to the WSO2 Identity Server and go to <strong>Identity Providers -&gt; Add </strong>section to add a new IDP for email OTP. And fill the below attributes with given values.</li></ul><ol><li>Identity Provider Name: <strong>EmailOTP</strong></li><li>Federated Authenticators -&gt; Email OTP Configurations: <strong>tick the Enable checkbox</strong></li></ol><ul><li>Then register the IDP by clicking the <strong>register</strong> button.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bjlqZtKS0g8_NYQBMsUOsQ.png" /><figcaption>EmaiOTP IDP</figcaption></figure><p><strong>Step 4: Configuring SP for API Manager management console</strong></p><ul><li>In the WSO2 Identity Server, go to <strong>Service Providers -&gt; Add </strong>section to create an SP for API Manager management console. In there, give a suitable name for SP and click the <strong>Register</strong> button.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c4HVWeAkg4qwnLJVnbcDwQ.png" /><figcaption>SP Name</figcaption></figure><ul><li>Go to the <strong>Inbound Authentication Configuration -&gt; SAML Web SSO Configuration </strong>and click <strong>Configure </strong>to add the SP’s details. After entering the configs, click the <strong>Register </strong>button.</li></ul><ol><li>Issuer: <strong>API-Manager-Carbon (</strong>which we configured in step 3)</li><li>Assertion Consumer URLs: <a href="https://localhost:9444/acs"><strong>https://localhost:9444/acs</strong></a><strong> </strong>(ACS URL of the AM carbon console)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-DdxvSR5hpx4w87cdukUgg.png" /><figcaption>SAML Config</figcaption></figure><ul><li>Then go to <strong>Local &amp; Outbound Authentication Configuration -&gt; Advanced Configurations </strong>section.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YxNBhlJN6xGVk9M7nelACQ.png" /><figcaption>Advanced Configurations</figcaption></figure><ul><li>Click <strong>Add Authentication Step </strong>and select <strong>Add Authenticator</strong> as<strong> basic </strong>of<strong> Local Authenticators </strong>list to add <strong>basic authenticator</strong> as the1st authentication step.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kAARia-4dCv9LrUPLpMWrg.png" /><figcaption>1st authentication step</figcaption></figure><ul><li>Again click <strong>Add Authentication Step </strong>and select <strong>Add Authenticator</strong> as<strong> EmailOTP </strong>of<strong> Federated Authenticators </strong>list to add <strong>EmailOTP</strong> as the 2nd authentication step.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MltjXC8OXYjAI9-8SvBXvw.png" /><figcaption>both authentication steps</figcaption></figure><ul><li>Then click the <strong>Update </strong>button to save the configurations.</li></ul><p><strong>Step 5: Configuring user related attributes</strong></p><ul><li>Go to <strong>Identity -&gt; Claims -&gt; Add -&gt; Add Local Claim </strong>and create and add the <strong>DisableEmailOTP</strong> claim with below details.</li></ul><ol><li>Claim URI: <a href="http://wso2.org/claims/identity/emailotp_disabled"><strong>http://wso2.org/claims/identity/emailotp_disabled</strong></a></li><li>Display Name: <strong>DisableEmailOTP</strong></li><li>Description: <strong>DisableEmailOTP</strong></li><li>Mapped Attribute (s): <strong>title</strong></li><li>Supported by Default: <strong>checked</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aJWhiX6Cn_zxxqgXmuo2WA.png" /><figcaption>DisableEmailOTP</figcaption></figure><ul><li>Go to <strong>Identity -&gt; Users and Roles -&gt; List -&gt; Users </strong>and choose the user you want to test the email OTP and select his/her <strong>UserProfile -&gt; default </strong>and add a valid email address for that user to get the OTP code with other mandatory attributes (First Name &amp; Last Name) and update the user profile.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ylUQRYTyB78AwmswnBtKhA.png" /><figcaption>Email in the user profile</figcaption></figure><p><strong>Step 6: Allowing less secure apps in Google</strong></p><ul><li>This step is essential in this scenario since Gmail is acting as the email OTP sender. Go to the <a href="https://myaccount.google.com/lesssecureapps">https://myaccount.google.com/lesssecureapps</a> page in using your sender Gmail address. Ans set <strong>Allow less secure apps: ON </strong>to allow WSO2 IS to send emails using that particular email address.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l1oxgk-Oz3BjSeIg3yb7IQ.png" /><figcaption>Allowing less secure apps</figcaption></figure><ul><li>If the above access is not on Google, will send a <strong>Critical Security Alert </strong>email to the sender email address saying that a sign-in attempt was blocked like below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T5rSeQ1Lupr9Tf1kmmzjyg.png" /><figcaption>Sign-in blocked</figcaption></figure><ul><li>And at the same time, WSO2-IS will throw below error to inform that email sending has failed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t86RuDe6k89IG98sdElZrg.png" /><figcaption>Email Publisher error</figcaption></figure><p><strong>Step 7: Login to the WSO2-AM Management Console</strong></p><ul><li>Go to the login page of WSO2-AM management console <a href="https://localhost:9444/carbon">https://localhost:9444/carbon</a>, it will take you to the SSO landing page of WSO2-IS.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KoUpUoBnjUbe3RQaQaalkA.png" /><figcaption>SSO Landing page</figcaption></figure><ul><li>Once the user credentials are entered and <strong>SIGN IN </strong>button is clicked, it will be redirected to the email-authentication endpoint to enter the email OTP code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_OSy1KIcub868mGOha5l4g.png" /><figcaption>Email OTP code</figcaption></figure><ul><li>At this point, an OTP code will be sent to the user’s email address like below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mQefdSPsuOf2wcskROh67Q.png" /></figure><ul><li>Once the received OTP code is entered in the <strong>Email Verification</strong> textbox, the user will be successfully authenticated and logged in to the WSO2-AM management console.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WRp7n7hD0pcCXODmq6-62Q.png" /><figcaption>WSO2-AM Management Console</figcaption></figure><p>Congrats !!!! now your WSO2-AM management console is successfully working with email OTP as the 2nd-factor authentication. <br>:)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8590404f1cf1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Changing default keystore passwords in WSO2 API Manager-3.0.0]]></title>
            <link>https://medium.com/@randima.somathilaka/changing-default-keystore-passwords-in-wso2-api-manager-3-0-0-897b0918eb88?source=rss-a7024b5aaf3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/897b0918eb88</guid>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[wso2am]]></category>
            <category><![CDATA[keystore]]></category>
            <dc:creator><![CDATA[Randima Somathilaka]]></dc:creator>
            <pubDate>Wed, 11 Mar 2020 18:00:16 GMT</pubDate>
            <atom:updated>2020-03-24T12:37:30.739Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UZ0ekBFz9jaWnEgBPQEdTw.jpeg" /><figcaption><a href="https://wso2.com/api-manageme">https://wso2.com/api-manageme</a></figcaption></figure><p>While playing around WSO2’s newest API product WSO2 API Manager-3.0.0, I was bit stuck in changing default password in wso2carbon.jks keystore and configuring it properly for API Manager to work without failing.</p><p>To make that happen without an issue I have followed below steps</p><p><strong>Step 1 : Changing the passwords in the keystore</strong></p><ol><li><strong>Changing Keystore Password</strong></li></ol><pre>keytool -storepasswd -new <strong>&lt;newPassword&gt;</strong> -keystore &lt;WSO2AM_HOME&gt;/repository/resources/security/wso2carbon.jks</pre><p>In the above command newPassword is your new password for the keystore. This command will prompt below query where you have to provide the current password for the keystore. Which is wso2carbon by default.</p><pre>Enter keystore password: wso2carbon</pre><p>2. <strong>Changing key password</strong></p><pre>keytool -keypasswd -alias wso2carbon -keystore &lt;WSO2AM_HOME&gt;/repository/resources/security/wso2carbon.jks</pre><p>This will prompt below queries where you have to provide the all the password values as below.</p><ul><li>current password for the keystore which we set in the previous step</li><li>current key password for the keystore which is wso2carbon by default.</li><li>new password for the key password -WSO2 recommends to use the same password as keystore password and key password.</li></ul><pre>Enter keystore password:  <strong>&lt;newPassword&gt;</strong> <br>Enter key password for &lt;wso2carbon&gt; wso2carbon &lt;-- old keypassword New key password for &lt;wso2carbon&gt;: <strong>&lt;newPassword&gt;</strong> <br>Re-enter new key password for &lt;wso2carbon&gt;: <strong>&lt;newPassword&gt;</strong></pre><p>These steps will change the passwords in the default keystore of WSO2 API Manager.</p><p><strong>Step 2 : Updating the Password Configurations</strong></p><p>Now, we have to configure these passwords in the new <strong>deployment.toml </strong>resides in &lt;WSO2_AM&gt;/repository/conf folder in the API Manager-3.0.0 product pack.</p><ol><li><strong>Configuring passwords</strong></li></ol><p>The new passwords should be stored at the end of the <strong>deployment.toml</strong> file under secrets section as below. Be sure to add these in the very bottom of the <strong>deployment.toml </strong>to avoid errors caused by ciphertool.</p><pre>[secrets] <br>keystore_password = &quot;[<strong>&lt;newPassword&gt;</strong>]&quot; <br>key_password = &quot;[<strong>&lt;newPassword&gt;</strong>]&quot;</pre><p>2. <strong>Configuring keystores</strong></p><p>Since we have changed the default passwords for the <strong>wso2carbon.jks </strong>keystore, all the three types of keystore configurations uses this keystore by default should be updated. The deployment.toml file configurations will look like below.</p><pre>[keystore.tls] <br>file_name =  &quot;wso2carbon.jks&quot; <br>type =  &quot;JKS&quot; <br>password =  &quot;$secret{keystore_password}&quot; <br>alias =  &quot;wso2carbon&quot; <br>key_password =  &quot;$secret{key_password}&quot;[keystore.primary] </pre><pre>[keystore.primary] <br>file_name =  &quot;wso2carbon.jks&quot; <br>type =  &quot;JKS&quot; <br>password =  &quot;$secret{keystore_password}&quot; <br>alias =  &quot;wso2carbon&quot; <br>key_password =  &quot;$secret{key_password}&quot;  </pre><pre>[keystore.internal] <br>file_name =  &quot;wso2carbon.jks&quot; <br>type =  &quot;JKS&quot; <br>password =  &quot;$secret{keystore_password}&quot; <br>alias =  &quot;wso2carbon&quot; <br>key_password =  &quot;$secret{key_password}&quot;</pre><p><strong>Step 3: Encrypting the passwords</strong></p><p>Since we have stored the passwords in plain text in the <strong>deployment.toml</strong> file, now we have to encrypt the passwords. In order to that run the below command in &lt;WSO2_AM&gt;/bin folder, which will encrypt the secrets we stored in the <strong>deployment.toml</strong> file, with the cipher tool comes with WSO2 products.</p><pre>./ciphertool.sh -Dconfigure</pre><p>The command will ask for the internal keystore password, which we have set in the step 1. Once the correct password is given, the encryption will happen without an issue.</p><pre>[Please Enter Internal KeyStore Password of Carbon Server : ]<strong>&lt;newPassword&gt;</strong></pre><pre><br>Internal KeyStore of Carbon Server is initialized Successfully</pre><pre><br>Encryption is done Successfully</pre><pre><br>Encryption is done Successfully</pre><pre><br>Secret Configurations are written to the property file successfully</pre><p>Successful completion of this command will overwrite the plain text secrets with the encrypted values in the <strong>deployment.toml</strong> file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CYHYUessgYSYB0VQ.png" /><figcaption>Encrypted secrets</figcaption></figure><p><strong>Step 3: Starting the Server</strong></p><p>Start the API Manager server by running ./wso2server.sh command in &lt;WSO2_AM&gt;/bin folder.</p><p>This command will ask for the new keystore password to run the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NY2yj7aQ1X5HShj7.png" /><figcaption>Keystore password prompt</figcaption></figure><p>Once the correct password is provided, server will start without a hassle. And <strong>https </strong>calls to the API Manager will work perfectly<strong>. :)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=897b0918eb88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ansible throws PyMySQL module required error]]></title>
            <link>https://medium.com/@randima.somathilaka/ansible-throws-pymysql-module-required-error-b93e81661c6a?source=rss-a7024b5aaf3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b93e81661c6a</guid>
            <dc:creator><![CDATA[Randima Somathilaka]]></dc:creator>
            <pubDate>Wed, 12 Feb 2020 13:19:43 GMT</pubDate>
            <atom:updated>2020-02-13T04:33:59.325Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oHPBUHf-vA_vxacB1nUTkw.jpeg" /><figcaption><a href="https://www.oreilly.com/">https://www.oreilly.com</a></figcaption></figure><p>When I was trying to create a MySQL database in my local machine using an ansible-playbook, it was constantly giving me this error below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nMua7QheUa6Edwm2d3FRsA.png" /><figcaption>Error in PyMySQL 1</figcaption></figure><p>Where my machine was in macOS catalina and Python 3.8 was already installed there.</p><p>As the first step, I installed the PyMySQL module using pip3 command.</p><pre>pip3 install pymysql</pre><p>The module was installed successfully, but when I try to run the ansible-playbook, error was still there. Therefore, to make sure the module is installed, I have added a additional task in my task main.yml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*0Sv1K5laJtG7rEtUWPgJjQ.png" /><figcaption>Check module exists</figcaption></figure><p>The result was as below where ansible says the module is present in the new step and not present while doing database creation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F9Elk_YP6-r3RT-gCXal-g.png" /><figcaption>Error in PyMySQL 2</figcaption></figure><p>So I was confused!!!. Since I was running this ansible-playbook in my local machine there couldn’t be a difference regarding the module’s status.</p><p>After spending some time on this issue, I was able to find out the bugger :D</p><p>Ansible in my macOs machine is installed using <strong>homebrew</strong>. Which uses its own Python setup. So what you have to do is install the required module in my case <strong>PyMySQL, </strong>inside this<strong> homebrew ansible Python</strong>.</p><p>You can check this Python in <strong>/usr/local/Cellar/ansible/&lt;ansible_version&gt;/libexec/bin/ </strong>location.</p><p>Installing PyMySQL module inside this Python with ansible version 2.9.4 will be as below.</p><pre>/usr/local/Cellar/ansible/2.9.4/libexec/bin/pip3 install pymysql</pre><p>Finally!!!</p><p>I was able to run my ansible-playbook to create a database in local mysql server without an issue :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0LdW5XDP-IdEXqdzgrcPWg.png" /><figcaption>Ansible-playbook successful</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b93e81661c6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resolving WSO2 API Manager DB Scripts throwing errors in MySQL 5.6]]></title>
            <link>https://medium.com/@randima.somathilaka/resolving-wso2-api-manager-db-scripts-throwing-errors-in-mysql-5-6-578707151286?source=rss-a7024b5aaf3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/578707151286</guid>
            <dc:creator><![CDATA[Randima Somathilaka]]></dc:creator>
            <pubDate>Thu, 23 Jan 2020 13:02:52 GMT</pubDate>
            <atom:updated>2020-02-03T06:01:33.877Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/798/0*QzG2Ishu2mbnzkXy.jpeg" /></figure><p>A step of configuring WSO2 API Manager and WSO2 Identity Server as Key Manager setup is to execute database scripts related to <strong>AM_DB</strong>, <strong>UM_DB</strong> and <strong>REG_DB</strong> in a database engine. I was stuck with this step for a couple of hours as my database engine was giving errors. My server setup was as below.</p><pre>OS : macOS Catalina 10:15.2<br>DB : MySQL Ver 14.14 Distrib 5.6.47, for osx10.15 (x86_64)<br>WSO2AM : 2.5.0<br>WSO2ISKM : 5.6.0</pre><p>The <strong>AM_DB</strong> MySQL script<strong>&lt;API-M_HOME&gt;/dbscripts/apimgt/mysql.sql</strong>, was giving below two error messages while executing. The error <strong>1709</strong> was there for four times and the the error <strong>1071</strong> was once.</p><pre>ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes.</pre><pre>ERROR 1071 (42000): Specified key was too long; max key length is 3072 bytes</pre><p>The error <strong>1709</strong> can occur for<strong> UM_DB </strong>or<strong> REG_DB </strong>as well. The <a href="https://docs.wso2.com/display/AM250/Installing+and+Configuring+the+Databases#Eg-MySQL">official WSO2 documentation </a>suggests a fix for this error in Windows OS. Same fix can be applied to macOS as well. Which is to create the database using<strong> latin1 character set</strong>.</p><pre>mysql&gt; create database &lt;DATABASE_NAME&gt; character set latin1;</pre><p>The error <strong>1071</strong> was giving by the below index creation SQL statement in the <strong>apimgt/mysql.sql</strong>. Which doesn’t allow to create a MySQL index with a table holding a column with VARCHAR(1024).</p><pre>CREATE INDEX IDX_IDN_SCIM_GROUP_TI_RN_AN ON IDN_SCIM_GROUP (TENANT_ID, ROLE_NAME, ATTR_NAME);</pre><p>The <strong>IDN_SCIM_GROUP</strong> table creation SQL statement is as below.</p><pre>CREATE TABLE IF NOT EXISTS IDN_SCIM_GROUP (<br>            ID INTEGER AUTO_INCREMENT,<br>            TENANT_ID INTEGER NOT NULL,<br>            ROLE_NAME VARCHAR(255) NOT NULL,<br>            ATTR_NAME VARCHAR(1024) NOT NULL,<br>            ATTR_VALUE VARCHAR(1024),<br>            PRIMARY KEY (ID)<br>)ENGINE INNODB ;</pre><p>Fix for this issue with MySQL index is to compress row data of the above table while creating the table or by altering the table.</p><pre>CREATE TABLE IF NOT EXISTS IDN_SCIM_GROUP (<br>            ID INTEGER AUTO_INCREMENT,<br>            TENANT_ID INTEGER NOT NULL,<br>            ROLE_NAME VARCHAR(255) NOT NULL,<br>            ATTR_NAME VARCHAR(1024) NOT NULL,<br>            ATTR_VALUE VARCHAR(1024),<br>            PRIMARY KEY (ID)<br>)ENGINE INNODB<strong> ROW_FORMAT=DYNAMIC</strong>;</pre><p>Here I have used the <strong>ROW_FORMAT=DYNAMIC </strong>to compress the data. To know more above the row formats refer the <a href="https://dev.mysql.com/doc/refman/5.6/en/innodb-row-format.html">MySQL official documentation</a>.</p><p>Since the DYNAMIC row format is only supported by the Barracuda file format, the following SQL statements should be executed <strong>before</strong> the running the <strong>apimgt/mysql.sql</strong> script.</p><pre>set global innodb_file_format = BARRACUDA;<br>set global innodb_large_prefix = ON;</pre><p>These fixes in the MySQL 5.6 setup and the <strong>apimgt/mysql.sql </strong>script will help to resolve errors while setting up the databases for WSO2 API Manager 2.5.0 setup. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=578707151286" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Openshift Origin -Creating an Opaque Secret]]></title>
            <link>https://medium.com/@randima.somathilaka/openshift-origin-creating-an-opaque-secret-de35b892c2e1?source=rss-a7024b5aaf3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/de35b892c2e1</guid>
            <category><![CDATA[store]]></category>
            <category><![CDATA[openshift-origin]]></category>
            <category><![CDATA[openshift]]></category>
            <category><![CDATA[opaque]]></category>
            <category><![CDATA[secrets]]></category>
            <dc:creator><![CDATA[Randima Somathilaka]]></dc:creator>
            <pubDate>Fri, 06 Sep 2019 17:23:06 GMT</pubDate>
            <atom:updated>2019-09-06T17:36:55.408Z</atom:updated>
            <content:encoded><![CDATA[<p>Opaque secrets can store information like, parameters, credentials, key-store values etc inside Openshift Origin projects.</p><p>There are several types of secrets used in Openshift Origin. You can find more details about these in <a href="https://docs.openshift.com/container-platform/3.9/dev_guide/secrets.html#types-of-secrets">Openshift Origin documentation</a>.</p><p>According to the official documentation,</p><blockquote>An <em>opaque</em> secret, allows for unstructured <strong>key:value</strong> pairs that can contain arbitrary values.</blockquote><p>Go to the <strong>Resources-&gt;Secrets </strong>section in your Openshift project and it will list the available secrets for your project.</p><p>But in here, you cannot create an <strong>opaque type</strong> secret using the <strong>Create Secret</strong> option in the upper right hand corner. This article will provide a step by step guide to create an opaque secret inside an Openshift project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MxhsioT61TYoSuWQBvsfeg.png" /><figcaption>Available Secret List</figcaption></figure><p>Here I am going to store the parameters needed for a MySQL database deployment, as an opaque secret.</p><h3>Template YAML</h3><p>A template YAML which is constructed as below, should be created to add an opaque secret in Openshift Origin.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb68583f06d6369201caf7b9941ce52e/href">https://medium.com/media/eb68583f06d6369201caf7b9941ce52e/href</a></iframe><p>The sections of the template are explained below.</p><ul><li>apiVersion -Any Openshift template specifies used <strong>Openshift apiVersion</strong> here</li><li>kind -This specifies the <strong>Openshift resource </strong>this template is being created for. In this case a “<strong>secret</strong>”</li><li>metadata -This contains meta-data of the resource being created. Such as name of the secret</li><li>type -This secret is in type of “<strong>opaque</strong>”</li><li>data -This section contains the information we are going to <strong>store in this secret</strong>. Data should be added as <strong>key-value</strong> pairs and<strong> values should be base64 encoded</strong> and added to the YAML file.</li></ul><p>Following two methods can be used for creating a secret inside Openshift Origin.</p><h3>Creating the Secret using web console</h3><p>Secret can be created using Openshift web console.</p><p>Log in to your Openshift console using a web browser and navigate to the project the secret is going to be added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QiFrb1BpG9fvD8qK1MZWSA.png" /><figcaption>Project’s default view</figcaption></figure><p>Select the ‘<strong>import YAML/JSON</strong>” option from <strong>Add to Project</strong> drop-down in the upper right hand corner.</p><p>It will take you to the below pop-up window where you can browse the YAML file from your computer or copy and paste the content of the YAML file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*7n7Ec9crKV-y07z3Zj9emQ.png" /><figcaption>Import YAML/JSON</figcaption></figure><p>Once the content of the YAML file is loaded successfully, click the <strong>create</strong> button in the bottom of the pop-up window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*M3G1hCStwKeftMGKK1h_1w.png" /><figcaption>YAML content</figcaption></figure><p>Once the secret creation is successful, pop-up will show the below window with the name provided in the <strong>meta-data-&gt;name</strong> section of the template.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*xlc5JDLYxZ9i5dDo2K94nA.png" /><figcaption>Import status</figcaption></figure><h3>Creating the secret using OC commands</h3><p>Similarly, secret creation can be done using <a href="https://docs.openshift.com/container-platform/3.9/cli_reference/get_started_cli.html">OC commands</a>.</p><p>First, login to your Openshift cluster by executing OC login command and providing the password.</p><pre>oc login -u &lt;your_username&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*W-UptzRVJO-CG-OvwLm-RQ.png" /><figcaption>OC Login</figcaption></figure><p>Navigate to your project using</p><pre>oc project &lt;project_name&gt;</pre><p>Then execute the OC create command by providing the name of the template YAML .</p><pre>oc create -f &lt;template_yaml_name&gt;</pre><p>This will show you the below message with the name you have provided in the <strong>meta-data -&gt; name</strong> section in the template YAML.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*bizyEDqhAfkBBzdWo1-xyg.png" /><figcaption>OC create status</figcaption></figure><p>Any of the above two methods will create a secret inside the specified project.</p><p>Go to the <strong>Resources-&gt;Secrets</strong> section in the specified project. There, you will see the newly created <strong>opaque type</strong> secret with the name provided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lF7MV3bXweY7EPcpJLSm_g.png" /><figcaption>Secret list after import</figcaption></figure><p>Get the detailed view of the created secret, by clicking on the secret name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cq6z08G-A6cD5xUCv-XZUQ.png" /><figcaption>Imported Secret</figcaption></figure><p>By selecting <strong>Reveal Secret</strong> option, you can get the actual values stored in this secret. This option will show the <strong>decoded values</strong> of the secret in a Read-Only manner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h3un9ghjIosWlcuiLUjKIA.png" /><figcaption>Reveal secret</figcaption></figure><p>If you want to update the values inside this secret, <strong>Edit YAML</strong> option should be selected from the <strong>Actions drop-down </strong>in the upper right hand corner.</p><p>This will take you to the below window, where you can update the values of the secret. While updating, <strong>base64 encoded</strong> values should be provided in the YAML.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J87iMouSroWlwiRbC4hpHQ.png" /><figcaption>Edit YAML</figcaption></figure><p>Hope this article will help to resolve any confusions regarding opaque secret creation inside Opnshift Origin.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de35b892c2e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Openshift Origin- Deploying a persistent MySQL database -Part 1]]></title>
            <link>https://medium.com/@randima.somathilaka/openshift-origin-deploying-a-persistent-mysql-database-part-1-997c30f2da96?source=rss-a7024b5aaf3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/997c30f2da96</guid>
            <category><![CDATA[openshift-origin]]></category>
            <category><![CDATA[persistent]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[openshift]]></category>
            <dc:creator><![CDATA[Randima Somathilaka]]></dc:creator>
            <pubDate>Fri, 06 Sep 2019 10:26:41 GMT</pubDate>
            <atom:updated>2019-09-06T10:26:41.864Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>OpenShift Origin</strong>, also known as OKD is a platform built around a core of <strong>Docker</strong> container packaging and <strong>Kubernetes</strong> container cluster management.</p><p>Openshift Origin provides comprehensive features to make it easy for DevOps engineers. You can easily deploy a MySQL database in a persistent manner in Openshift Origin using these features.</p><p>This example deployment was done in the <strong>3.9</strong> version of Openshift Origin distribution.</p><h3>MySQL Docker Image Stream</h3><p>By default, Openshift Origin has stored a MySQL docker images inside an <a href="https://docs.openshift.com/container-platform/3.9/architecture/core_concepts/builds_and_image_streams.html#image-streams"><strong>Openshift Image Stream</strong> </a>which contains docker images compatible for deploying in Openshift Origin.</p><p>This image stream can be found in the <strong>openshift </strong>project.</p><p>Once you logged-in to the Openshift Origin web console, project list can be found in the right hand corner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R8X4cFLoAVid2kYW-vpLMg.png" /><figcaption>Openshift Origin Catalog</figcaption></figure><p>By clicking the <strong>View All</strong>, all the projects created in the Openshift Cluster can be listed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qx65pUaeze00EZ7OUnmDVQ.png" /><figcaption>All the projects inside the OSO cluster</figcaption></figure><p>Select the project named “<strong>openshift</strong>” and go to the <strong>Builds-&gt;Images</strong> section inside that project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WZnn57No-kn3qptq6rY4lQ.png" /><figcaption>openshift project</figcaption></figure><p>In there you can find the <strong>mysql </strong>image stream which contains the MySQL docker images to deploy in Openshift.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rJTMUu9w7NriCCNjbIWbcg.png" /><figcaption>mysql image stream</figcaption></figure><p>As you can see these images are from <strong>docker.io</strong>. Therefore more details on the images can be found in Docker Hub.</p><p>Following link contains the details regarding, <strong>centos/mysql-57-centos-7 </strong>docker image.</p><p><a href="https://hub.docker.com/r/centos/mysql-57-centos7">https://hub.docker.com/r/centos/mysql-57-centos7</a></p><p>According to the description there, the docker image will need below parameters while running as a container.</p><ul><li>MYSQL_DATABASE</li><li>MYSQL_PASSWORD</li><li>MYSQL_ROOT_PASSWORD</li><li>MYSQL_USER</li></ul><h3>MySQL Openshift Template</h3><p>Already an<strong> </strong><a href="https://docs.openshift.com/container-platform/3.9/dev_guide/templates.html"><strong>Openshift Template</strong></a> has been added to this project, to deploy any of the docker images listed in the MySQL image stream.</p><p>It can be found inside the <strong>Resources-&gt;Other Resources </strong>section under <strong>Template</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kXTuYiNLis8uk4ld_T6LUg.png" /></figure><p>The template used to deploy the MySQL docker image is <strong>mysql-persistent.</strong> To see the content of this template, select <strong>Action-&gt;Edit YAML</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8b14psVM02pWrghfv_1X1A.png" /></figure><p>According to the template, it will need several parameters to deploy the mentioned MySQL image. We found details about these parameters in the MySQL docker image section as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YleuXKebV14bg9p7NIpp9A.png" /></figure><ul><li>MYSQL_DATABASE</li><li>MYSQL_PASSWORD</li><li>MYSQL_ROOT_PASSWORD</li><li>MYSQL_USER</li></ul><p>Now we have gathered the needed information for deploying a MySQL image in Openshift.</p><p>Let’s move on to the actual deployment of a MySQL in the Part 2 of this article series.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=997c30f2da96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fix Docker Engine install failure in Ubuntu]]></title>
            <link>https://medium.com/@randima.somathilaka/docker-engine-install-fails-in-ubuntu-3e70762c2187?source=rss-a7024b5aaf3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e70762c2187</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[failure]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[Randima Somathilaka]]></dc:creator>
            <pubDate>Fri, 06 Sep 2019 07:12:40 GMT</pubDate>
            <atom:updated>2019-09-06T17:32:24.145Z</atom:updated>
            <content:encoded><![CDATA[<h3>Fixing Docker Engine Installation Failure in Ubuntu</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Q3TsyinH1YVSkH6NdVBDA.png" /><figcaption><a href="https://docs.docker.com/install/linux/docker-ce/ubuntu/">https://docs.docker.com/install/linux/docker-ce/ubuntu/</a></figcaption></figure><p>While installing docker in your machine, Docker Engine -Community and containerd should be installed as a step. The general command to install this in Ubuntu is</p><pre>sudo apt-get install docker-ce docker-ce-cli containerd.io</pre><p>This command will install the latest version of Docker Engine from the available repositories. Sometimes this command will get failed with an error as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o4qne9mFG09zRnu4pLfnMA.png" /><figcaption>Docker Engine Install Failure</figcaption></figure><p>When multiple docker repositories enabled, above command will always install the highest version of the Docker Engine. This will not always appropriate when considering the stability.</p><p>Let’s first check what are the available versions and repositories for Docker Engine inside our Ubuntu machine.</p><p>Next two commands will help to list down the cached <strong>docker-ce</strong> repositories in apt-cache.</p><pre>apt-cache policy docker-ce</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*QxzNZEYI9T_WvjRJqDw9cQ.png" /><figcaption>apt-cache-policy</figcaption></figure><pre>apt-cache madison docker-ce</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ac6xa8gzZ2xs0SIcHDI4MQ.png" /><figcaption>apt-cache madison</figcaption></figure><p>In my case, there were multiple <strong>docker-ce</strong> repositories available and the command was trying to install latest version which was “<strong>5:19.03.2~3–0~ubuntu-bionic</strong>”.</p><p>As this version was not stable with Ubuntu 18.04, installing Docker Engine was failing with an error.</p><p>In this point, you have to specify a Docker Engine version which is stable with your OS while installing.</p><pre>sudo apt-get install docker-ce=&lt;VERSION_STRING&gt; docker-ce-cli=&lt;VERSION_STRING&gt; containerd.io</pre><p>Refer the example below.</p><pre>sudo apt-get install docker-ce=5:18.09.9~3–0~ubuntu-bionic docker-ce-cli=5:18.09.9~3–0~ubuntu-bionic containerd.io</pre><p>This will successfully install the mentioned Docker Engine version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K_IPVG_crnnwrbclTC7iwg.png" /><figcaption>Docker EngineInstall Success</figcaption></figure><p>Check the installed Docker version</p><pre>docker — version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*67HKD_7iDp8wCVDNU3mJXQ.png" /><figcaption>Installed Docker Version</figcaption></figure><p>Check the status of the Docker service</p><pre>sudo service docker status</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AvtWoK2xn029A-pEtLzAjA.png" /><figcaption>Docker Service Status</figcaption></figure><p>Hope this will help you to find the root cause when your Docker Engine installation is getting failed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e70762c2187" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Openshift Origin deploying from external docker registry- Part 1]]></title>
            <link>https://medium.com/@randima.somathilaka/openshift-origin-deploying-from-external-docker-registry-part-1-9190ae301546?source=rss-a7024b5aaf3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9190ae301546</guid>
            <category><![CDATA[okd]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[micronaut]]></category>
            <category><![CDATA[openshift]]></category>
            <category><![CDATA[dockerhub]]></category>
            <dc:creator><![CDATA[Randima Somathilaka]]></dc:creator>
            <pubDate>Mon, 03 Jun 2019 18:15:45 GMT</pubDate>
            <atom:updated>2019-07-02T12:30:47.556Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cS3HJU6zQeFEIiNfZlTHwg.png" /><figcaption><a href="https://www.okd.io/">https://www.okd.io/</a></figcaption></figure><p><strong>OpenShift Origin</strong>, also known lately as OKD (Origin Community Distribution) is built around a core of Docker container packaging and Kubernetes container cluster management.</p><p>It is easy to setup a single node cluster for development purposes with Openshift Origin. Refer the <a href="https://medium.com/@maheshacharya_44641/install-openshift-origin-on-ubuntu-18-04-7b98773c2ee6">Install OpenShift Origin on Ubuntu 18.04</a> for more details.</p><p>As Openshift Origin is supported with internal docker registry, it is sometimes bit confusing while connecting external docker registry to pull images for the deployments in the Openshift Origin. This article and the next coming article will describe how to resolve those issues and confusions.</p><p>Part 1 of the article series will describe how to pull images from DockerHub to Openshift Origin Version 3.9.0.</p><p><strong>OpenShift Origin Console</strong></p><ol><li>Following oc command will start the cluster</li></ol><pre>oc cluster up</pre><p>If you are getting below error follow the steps mentioned below.</p><blockquote>error: FAIL<br> Error: did not detect an — insecure-registry argument on the Docker daemon<br> Solution:</blockquote><blockquote>Ensure that the Docker daemon is running with the following argument:<br> — insecure-registry 172.30.0.0/16</blockquote><p>First add the given IP list as insecure registries in the /etc/docker/daemon.json file as below.</p><pre>{<br>    &quot;insecure-registries&quot; : [ &quot;172.30.0.0/16&quot;]<br>}</pre><p>Next restart the docker service.</p><pre>service docker restart</pre><p>Then start the Openshift cluster with “cluster up” command.</p><p>Once cluster is up, you can login into the Openshift console and select default development project named “<strong>MyProject</strong>”. Project is a similar concept as namespace in Kuberenetes. In Project you can do a deployment using 3 methods as described in the following image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EBNIgPKCBFHH-C-yJQ98nQ.png" /><figcaption>Deployment methods in a Openshift Project</figcaption></figure><p><strong>Setting Up the Docker Image</strong></p><p><strong>Deploy Image</strong> method will be used for this article, which will pull an image for deployment from an external docker registry or from another project in the Openshift Origin.</p><p>In the example, a docker image built from a <a href="https://github.com/randimaS/micronaut-microservices/tree/master/hello-service"><strong>Micronaut</strong> service</a> is tagged as <strong>ranso/hello-service</strong> and stored in <strong>DockerHub</strong> will be used for the deployment.</p><p>Once this image is searched for deployment by the Openshift, it will give the below warning message.</p><blockquote>Image <strong>ranso/hello-service:latest</strong> runs as the <strong>root</strong> user which might not be permitted by your cluster administrator.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UnnJ-rcgr4XMYWpUu4XbrA.png" /><figcaption>Root user Docker image build warning</figcaption></figure><p>As Openshift Origin is more concerned with security, it will ensure the pod security by <strong>not allowing containers to run their processes as ROOT</strong>. Of course you can bypass this security check by updating privileges in default <a href="https://docs.openshift.com/container-platform/3.9/admin_guide/manage_scc.html#enable-images-to-run-with-user-in-the-dockerfile">Security Context Constraint</a>. For this scenario, let’s build the docker image with a different privileged user.</p><pre>RUN adduser -D -u 8877 randi<br>USER randi</pre><p>Above two lines in the <a href="https://github.com/randimaS/micronaut-microservices/blob/master/hello-service/Dockerfile">Dockerfile</a> will create a privileged user named “randi” and build the docker image using that user.</p><p><strong>Deploying a docker image stored in a Public Repository in Docker Hub</strong></p><p>The docker image stored in the <strong>Docker Hub public repository</strong>, is now ready for the deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_jl6a7inygOSEAAFN6aHmw.png" /><figcaption>Docker image is ready to be deployed</figcaption></figure><p>Once deploy button is clicked, an Openshift deployment will be triggered for this docker image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SJqStW3zrgJynYArwQgw0A.png" /><figcaption>Docker image is deployed</figcaption></figure><p>An Openshift deployment config will be created with the docker image name inside <strong>Applications-&gt;Deployments</strong> and below three components will automatically be added inside the Kubernetes cluster and the internal docker registry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZpzA9KS62yNHloI-L8WkRA.png" /><figcaption>Hello Service Deployment Config</figcaption></figure><ol><li><em>An </em><a href="https://docs.openshift.com/container-platform/3.9/architecture/core_concepts/builds_and_image_streams.html#image-streams"><em>Image Stream</em></a></li></ol><p>Image streams are used for referencing docker images in Openshift Origin. These image streams are created inside the <strong>internal docker registry</strong> packed with Openshift Origin. Once configured, deployments can watch an image stream for notifications when new images are added and react by performing a redeployment. Image streams can be viewed in <strong>Builds-&gt;Images </strong>in the console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X462sYrTI9IVi9Lk82OuTQ.png" /><figcaption>Hello Service Image Stream</figcaption></figure><p>2. <em>A </em><a href="https://docs.openshift.com/container-platform/3.9/architecture/core_concepts/pods_and_services.html#pods"><em>Pod</em></a></p><p>Openshift uses the same Kubernetes pod concept to run one or multiple containers as a one single unit. In a default deployment one pod will be created. But you can easily increase the replicas using <strong>Applications-&gt;Pods </strong>section<strong> </strong>in<strong> </strong>the Openshift console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vha2sRhwzkmHkBWgO878Tg.png" /><figcaption>Hello-Service Pod</figcaption></figure><p>3. <em>A </em><a href="https://docs.openshift.com/container-platform/3.9/architecture/core_concepts/pods_and_services.html#services"><em>Service</em></a></p><p>Openshift leverages Kubernetes service concept which is used to proxy the replicated pods to balance the load coming to them. While keeping the service consistent and without breaking, you can add or remove the replicated pods. Service are listed under <strong>Applications-&gt;Services </strong>in the console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1w8h5Ws48VeN3lRxyCPGLg.png" /><figcaption>Hello Service service</figcaption></figure><p><a href="https://docs.okd.io/1.5/architecture/core_concepts/routes.html"><em>Routes</em></a></p><p>After the deployment is success with the above three components, to expose the service to the external world, a <a href="https://docs.okd.io/1.5/architecture/core_concepts/routes.html">route</a> can be easily created and exposed with a DNS through Openshift manually. Routes can be created with below command by giving service name or using the console as well. Routes are shown in the <strong>Applications-&gt;Routes </strong>section in the console.</p><pre>oc expose svc/hello-service</pre><p>By default, route will be created according to the below format</p><blockquote>servicename-namespace.openshiftIP.nip.io</blockquote><p><a href="https://nip.io/">nip.io</a> is a simple DNS for IP addresses which Openshift Origin adds by default. You can add your own DNS as a route suffix to the Openshift as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BWYQFWRNnqCLBL7RLOoPcQ.png" /><figcaption>Hello Service Route</figcaption></figure><p>Now as the deployment is successful, container is up and running in the Openshift Origin. Using the route exposed, service inside the container can be easily invoked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*trehiwRAhSzfSfY_iL2N2g.png" /><figcaption>Invoking the Hello Service</figcaption></figure><p><strong>Deploying a docker image stored in a Private Repository in Docker Hub</strong></p><p>If the docker image is stored in a <strong>private repository in Docker Hub</strong>, below issues will be encountered. You can resolve them by following the steps mentioned in the next section.</p><ol><li>Accessing the private docker repository</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L1BqLwKsJw2tEssLOj_Yfw.png" /></figure><p>In order to access the private docker registry, docker secrets should be added to the Openshift using the below oc command or using the console.</p><pre>oc create secret docker-registry docker-hub-secret --docker-server=docker.io --docker-username=your-dockerhub-username --docker-password=your-dockerhub-password --docker-email=your-dockerhub-email</pre><p>A secret named “docker-hub-secret” will be created and can be viewed in <strong>Resources-&gt;Secrets</strong> section in the console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0E3fYkFLyP0Wzs5-2uh6NA.png" /><figcaption>Docker Hub Secret</figcaption></figure><p>Now the image is accessible for the deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nl2AJS9WyzOZlRTul2x0Tw.png" /></figure><p>2. Pulling from the private docker repository</p><p>Once the deploy button is clicked, deployment will be triggered. If we go to the <strong>Applications -&gt;Pods</strong> section, we can see two pods are running and one is failing with an error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SKrU5KaFHUlHYzw7ezuLMg.png" /><figcaption>Pods running while deployment</figcaption></figure><p>One is the pod who is facilitating the deployment which is suffixed with “<strong>-deploy</strong>”.<strong> </strong>When deployment is a triggered, Openshift will create a deploy pod to initiate the image deployment. This <strong>deploy-pod</strong> will create the actual pod where the docker image’s container will be running. Once the container is successfully up and running in the new pod , <strong>deploy-pod</strong> will be terminated automatically.</p><p>In this case, the actual pod is failing with an error. If we navigate to the <strong>Events</strong> section in that failing pod we can see the actual error details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zo9KaUegSWLTFO0TusH2_g.png" /><figcaption>Events in the failing Pod</figcaption></figure><p>As error shown in below, it says that Openshift is prohibited to pull from the mentioned private docker repository.</p><blockquote>Failed to pull image “ranso/hello-service@sha256:bb0fd840644599e73e78f118c7f5c5e1e2843900aceaa779603c9950fd22ac41”: rpc error: code = Unknown desc = Error response from daemon: pull access denied for ranso/hello-service, repository does not exist or may require ‘docker login’</blockquote><p>To fix this issue, we have to allow “<strong>docker image pulling</strong>” to the <a href="https://docs.openshift.com/container-platform/3.9/dev_guide/service_accounts.html#managing-allowed-secrets"><strong>default service account</strong></a> in Openshift by attaching the secret we created for the <strong>private Docker Hub repository. </strong>Following oc command will do this for us.</p><pre>oc secrets add serviceaccount/default secrets/docker-hub-secret --for=pull</pre><p>As the previous deployment is failed with retrying, we can trigger another deployment by clicking deploy button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8i-eUgPabQEEbY3ZJGi2Ig.png" /><figcaption>Failed deployment</figcaption></figure><p>Now the deployment #2 is successful with an up and running pod.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HikS3OwnntoLvdMto0p0Yw.png" /><figcaption>Successful deployment</figcaption></figure><p>Now with this article, you can easily link your external docker repository hosted in Docker Hub to Openshift Origin. :)</p><p>Let’s talk about how to connect a private docker repository <strong>hosted in your environment</strong> and <strong>Openshift Origin </strong>in the Part 2 of this article series.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9190ae301546" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[WSO2 ESB] Avoiding duplicate message sending in Store and Forward Pattern]]></title>
            <link>https://medium.com/@randima.somathilaka/wso2-esb-avoiding-duplicate-message-sending-in-store-and-forward-pattern-7cafe5d0afed?source=rss-a7024b5aaf3a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cafe5d0afed</guid>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[message-processor]]></category>
            <category><![CDATA[esb]]></category>
            <category><![CDATA[bm]]></category>
            <dc:creator><![CDATA[Randima Somathilaka]]></dc:creator>
            <pubDate>Wed, 21 Nov 2018 20:19:09 GMT</pubDate>
            <atom:updated>2018-11-26T04:31:22.237Z</atom:updated>
            <content:encoded><![CDATA[<p>Store and Forward Enterprise Integration pattern (EIP) helps to have guaranteed delivery as messages get stored and never get lost. Similarly this EIP can be used for back end service calls that can handle requests in a given rate.</p><p>Scheduled Message Forwarding Processor and Message Store components in WSO2 ESB, can be used to implement this pattern.</p><p>When configuring the Scheduled Forwarding Message Processor, following two properties should be set.</p><ul><li><strong>client.retry.interval</strong> : Message retry interval in milliseconds. Retry will happen when the back end is unreachable or back end is responding with a retry status code. Default values is 1000ms (1s)</li><li><strong>max.delivery.attempts</strong> : Maximum retry attempts before deactivating the processor. Default value is 4</li></ul><p>When using WSO2 MB as the message broker for Store and Forward setup with configuring the Message Processor max.delivery.attempts, if the ESB couldn’t get a success response from the Message Processor endpoint, it will retry for the configured <strong>max.delivery attempt</strong> count within configured <strong>client.retry.interval</strong> until the endpoint gives a successful response. If the endpoint did not give a success response within this count, Message Processor will be deactivated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/0*KfdsOJFmlb3Ui1zm.png" /></figure><p>The configuration <strong>AndesAckWaitTimeOut</strong> in WSO2 ESB, defines the waiting time before sending a reject body back to the message broker in case ESB cannot get a success response from the destination endpoint of the message. When a successful message delivery did not happen within this time period, ESB will pull the message again from the MB queue. Default value for the <strong>AndesAckWaitTimeOut </strong>configuration is 30 seconds.</p><p>While configuring the Message Processor, if the multiplication of <strong>client.retry.interval </strong>value and the<strong> max.delivery.attempts </strong>value is less than the <strong>AndesAckWaitTimeOut </strong>value, the Store and Forward scenario will be working fine. Here <strong>max.delivery.attempts </strong>also considered, as for the worst case scenario, ESB acknowledgment can be sent in the last delivery attempt as well.</p><p>Example 1.</p><p>For the default values, it will work fine.</p><p><strong>(client.retry.interval=1)*(max.delivery.attempts=4) &lt; (AndesAckWaitTimeOut=30)</strong></p><p>Example 2.</p><p>In a scenario like <strong>client.retry.interval </strong>is 10s , <strong>max.delivery.attempts </strong>is 5 and <strong>AndesAckWaitTimeOut </strong>is in default value, it will result a erroneous message delivery.</p><p>Let’s see how this error scenario occurs.</p><p>Considering the worst case scenario when the back end responds in the last delivery attempt, 50 seconds has been elapsed since the first attempt. While the retry mechanism is happening from Message Processor, as the <strong>AndesAckWaitTimeOut </strong>exceeds in 30 seconds, message will be again pulled by the ESB, resulting a duplication of message sending to back-end.</p><p>Therefore instead of attempting 5 times of message sending it will cause 6 attempts within 50 seconds. 5 from the Message Processor retry and 1 from the <strong>AndesAckWaitTimeOut </strong>exceeding.</p><p><strong>So how do we fix such a erroneous situation?</strong></p><p>This can be fixed by adding the new <strong>AndesAckWaitTimeOut </strong>value which is greater than the multiplication of <strong>client.retry.interval </strong>value and the<strong> max.delivery.attempts, </strong>like below in the <strong>wso2server.sh</strong> file resides in <strong>ESB_HOME/bin</strong> directory.</p><p>-DAndesAckWaitTimeOut=60000</p><p>This will make your Store and Forward setup with WSO2 ESB and MB working fine :)</p><p>References: <a href="https://docs.wso2.com/display/ESB500/Store+and+Forward+Using+JMS+Message+Stores">https://docs.wso2.com/display/ESB500/Store+and+Forward+Using+JMS+Message+Stores</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cafe5d0afed" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>