Friday, 25 September 2020

To know a Docker image exists with REST API

 Most of the time when it comes to docker, we play with using the CLI with 'docker' command. If we want to pull an image, tag an image, push an image we do all that with CLI only. However, apart from CLI, the docker repository supports varieties of REST API to do plenty of things and here I am planning to cover a few things like below

Manifest resource

The manifest rest resource can be used in a way how we want, for eg: if we want to know whether the image exists with a given tag then we can use the GET method of it

def checkAlreadyPresent(imageName, tag, bearerToken):
    auth_header = {'Authorization': ''}
    auth_header['Authorization'] = 'Bearer ' + bearerToken
    res = requests.get(
            url="https://docker.io/v2/" + imageName + "/manifests/" + tag,
            headers=auth_header)
    return res.status_code


You can also refer to

https://github.com/venkatesh-mohanram/continuous-learning/blob/master/docker/httpapiv2.md




Friday, 4 September 2020

mvn dependency:tree - rescuer during build issues

Maven is one of the very good build tools and is still popular among many users. Even though we use it for a long time, we use to remember or use only a limited number of its commands like 'mvn clean install', 'mvn package', mvn test' etc

we get to know many of its commands only when we face issues, one of the nice command is the 'mvn dependency:tree' to get all the dependencies including the transitive dependencies we have. In this blog, I am going to talk about this particular command

We should execute the below command from the folder where we have the pom.xml file

$ mvn dependency:tree

This will print all the dependencies from the root till the last jar, this will help to identify what are the transitive dependencies that we have.

We have varieties of options to fix the transitive deps error, 

1. Add the transitive dependency into <exclusions> list

If you have control over the dependency then you can do one of the following

2.  make the transitive deps in the provided scope https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope

Sunday, 15 March 2020

03 Kubernetes Secret for storing Oracle ATP wallet

Kubernetes Secret are used to store secrets during the setup of the cluster and then we can mount the same inside the docker containers. In this example, I am using it to store the Oracle ATP wallet which is used to talk to the ATP instance


kubectl create secret generic db-user-pass 
        --from-file=./cwallet.sso 
        --from-file=./ewallet.p12 
        --from-file=./keystore.jks 
        --from-file=./ojdbc.properties 
        --from-file=./sqlnet.ora 
        --from-file=./tnsnames.ora 
        --from-file=./truststore.jks


This is using the command line, apart from that even we can have a Secret Kind file similar to Deployment Kind and set it up using the 'kubectl apply'.

After this, we need to mount the secret as a volume and use it inside the container

apiVersion: v1
kind: Deployment
metadata:
  name: addition-svc-deployment
  labels:
    name: addition-svc
spec:
  volumes:
  - name: secret-volume
    secret:
      secretName: db-user-pass
  containers:
  - name: addition-svc-container
    image: addition-svc:latest
    volumeMounts:
    - name: secret-volume
      readOnly: true
      mountPath: "/etc/secret/atp-wallet"

Other links:
http://venkateshbook.blogspot.com/2019/05/kubernetes-commands.html
http://venkateshbook.blogspot.com/2019/05/kubernetes-yaml-definitions.html
http://venkateshbook.blogspot.com/2019/05/02-kubernetes-service-definition.html

Tuesday, 21 January 2020

Dandeli - an Experience not to miss

When we hear about the name Dandeli, the immediate thought we get will be the river rafting experience. In India the number of places we have the river rafting is very limited and in the Southern part of India, this is the most famous place for rafting.  The actual Dandeli is a small town in northern Karnataka and the real fun is in the mountain ranges and places near the Supa Dam reservoir.  

It is preferable to stay at least two nights as it will provide a pleasant stay in a jungle resort and will give time for water activities and sightseeing.  There are plenty of homestay, resorts, and hotels in all budgets. Most of the stay will quote including the water activities package as it is the main attracting there and they have tie-ups with the conducting agencies. In Dandeli, the water activities won't be there all over the year, it depends on the flow of water from the dam. If it is too huge then water activities are too dangerous and will be canceled, so it is advisable to check in advance and plan the trip.

The climate in Dandeli is modest, not too hot or too cold but at night it will be very cold. The mobile network is not so good, only in some places, we get the network and in some places, we will not. We stayed in a stay called 'Greenland Junglestay', it is run by Joshi, a friendly guy help to plan the itineraries well to cover most of the places. Also, speak to him and you will get a good deal for your stay. This stay is having its own farmland where they cultivate pepper, betel nuts. Near to that, we have water stream flows all through the day.

Greenland Junglestay

Betel nuts 

Sunrise in the jungle

Water stream near the stay

Apart from water activities, we have places like the honey park, Supa Dam viewpoint, Syntheri rock, nature walk etc.,





Video


Tuesday, 1 October 2019

My Journey with Gradle

In this blog, I will write about my experience in working with Gradle; most of the samples I have kept it in below github link for reference


https://github.com/venkatesh-mohanram/gradle-experiments

Converting the maven project in gradle:

Gradle has its utility which can easily convert maven project into a gradle project with one command. This will be very useful when we want to move from maven to a gradle build system. However at the time of writing, it does not support multi-project environments.
$gradle init
We need to execute the above command where we have the pom.xml file

Push to artifactory


Pushing to JFrog artifactory can be done either by using the JFrog Arifactory plugin or if we are using maven repo in artifactory then we can use the default maven plugin to push the jar into the artifactory which I found it to be simple and easy.


https://github.com/venkatesh-mohanram/gradle-experiments/tree/master/gradle-maven-publish

Force download dependency


If we want to download the dependencies everytime we build the code, then use the 'refresh-dependencies' option along with the build
$gradle build --refresh-dependencies


gradle wrapper


Gradle wrapper is a useful tool and helps in using the same gradle version anywhere we build our source code. Also, t works in the system where gradle is not installed as well.

Instead of using 'gradle' as a command use './gradlew'
$./gradlew build


.gitignore

By default, the .gitignore will contain build and .gradle file which we do not want to source control it


Setting the proxy while running

$./gradlew -Dhttps.proxyHost=<HOST> -Dhttps.proxyPort=<PORT> build

Thursday, 12 September 2019

Goa in the Monsoon

We went to Goa, India in the monsoon season. Initially, we thought will it be the right time or we should change but it seems to be a good time to visit as we get good discounts in stay, car rentals and water sports. Yes, water sports are there even in monsoon; I think not all are available but they have a good water sports package for monsoon.

Even we should be a little lucky when visiting in monsoon, if there are unfrequent showers then it will be good but if it is a non-stop rain then we will be forced to stay in the room. 


Car/Bike Rentals:

When it comes to car rentals, I would say in my experience that Goa is one the cheapest. The least it comes for Rs 1000 per day. There are plenty of providers, I went with https://saiyuri-travel-solutions.business.site/. If we want them to deliver the car to our preferred location, for example, like from Airport/RailwayStation then they have a fixed delivery/pick-up charge of Rs 300. You can book over the phone before you arrive but you will be paying only when you take the car.


Stay:

When we talk about Goa actually we refer/imagine to Beaches, shacks, night-life etc., and all these are very far away from the capital Panaji. So it is good if we book a stay near Baga or Calangute, from these places the beaches are walkable and we can come out at any time of the day and chill. Based on the budget and preference they are plenty of lodges, home-stay, serviced apartments are available. We preferred serviced apartment and booked in https://www.eternalwave.in/. They have very well maintained rooms but they do not have a good restaurant inside


Beaches and Shacks:

Beaches are open 24 hours and we can play, take a bath, dip the leg any time of the day. There are very good paid bathrooms and change rooms available at a very nominal cost. Parking is also available on almost all the beaches, but the parking near the Tito club is very expensive and it is Rs100 for 4 hours in other areas it would be just Rs20 for 4 hours. Shacks are the awesome experience in Goa, they just don't provide drinks they serve tasty, yummy, mouth-watering and delicious foods. We went almost every day to Shacks for food and relaxation. 

Baga beach has shallow water where kids can sit and enjoy the waves hitting them.






Water Sports:

We wanted to try something adventurous and not tried before sports and chose "Fly Board", the experience cannot be explained in words. It is a joy when we fly but a pain when we fell in the water. This is not in the sea but in the Chapora river. Definitely difficult for first-timer but we shouldn't give up and try the next time. In India, Goa is the only place where they have "Flyboard" activity.





Souvenirs:

We can buy cashews, dresses etc when we come back as a memory of the visit

Friday, 23 August 2019

Writing Custom Tasks in Gradle

Writing custom tasks in Gradle is very easy if we understand the lifecycle of its execution https://docs.gradle.org/current/userguide/build_lifecycle.html

Sample custom tasks from build.gradle file 

Copy of the build.gradle available in https://github.com/venkatesh-mohanram/gradle-experiments/blob/master/gradle-custom-tasks/build.gradle


class CustomParentTask extends DefaultTask {
String cv_var1
@TaskAction
void build() {
println "CustomParentTask:build() $cv_var1"
cv_var1 = "CHANGE IN BUILD"
}
}
task customParent(type: CustomParentTask) {
// Initialization
customParent.ext.var1 = 'INITIAL'
cv_var1 = customParent.ext.var1
println "customParent:Initialization"

// Execution
// doFirst -> build() -> doLast
doFirst {
custom.var1 = 'hello'
customParent.ext.var1 = 'World'
cv_var1 = customParent.ext.var1
println "customParent:doFirst"
}
doLast {
println "customParent:doLast"
}
}

class CustomTask extends DefaultTask {
@TaskAction
void build() {
println "CustomTask:build()"
}
}
task custom(type: CustomTask, dependsOn: customParent) {
// Initialization
custom.ext.var1 = ''
println "custom:Initialization"

// Execution
// doFirst -> build() -> doLast
doFirst {
println "custom:doFirst $custom.ext.var1 $customParent.var1"
}
doLast {
println "custom:doLast"
}
}


Execution of the custom task will result in the following output; if we notice the first execution all are the initialization code, followed by the execution phase. Within execution, it executes in the following order doFirst, class method and finally doLast

$ gradle custom

> Configure project :
customParent:Initialization
custom:Initialization

> Task :customParent
customParent:doFirst
CustomParentTask:build() World
customParent:doLast

> Task :custom
custom:doFirst hello World
CustomTask:build()
custom:doLast

BUILD SUCCESSFUL in 2s
2 actionable tasks: 2 executed