GIT/tree installation by chef cookbook

Install git and tree by using chef cook book

Note:yum/apt-get are resources in chef


first need to deploy server or use the chef server online create account(only for less than 5 nodes)

download chef repo after adding organization details






Then go to chef-repo and create cook book using the below commands(CMD PROMPT)

C:\Users\admin>cd C:\Users\admin\Desktop\chef-repo\cookbooks

C:\Users\admin\Desktop\chef-repo\cookbooks>chef generate cookbook linuxyum -b
C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/ffi-1.12.1-x64-mingw32/lib/ffi/struct.rb:207:in `layout': [DEPRECATION] Struct layout is already d
efined for class Windows::ServiceStructs::SERVICE_STATUS_PROCESS. Redefinition as in C:/opscode/chefdk/embedded/lib/ruby/gems/2.6.0/gems/win32-service
-2.1.4/lib/win32/windows/structs.rb:72:in `' will be disallowed in ffi-2.0. (StructuredWarnings::StandardWarning)
Generating cookbook linuxyum
- Ensuring correct cookbook content

Your cookbook is ready. Type `cd linuxyum` to enter it.

There are several commands you can run to get started locally developing and testing your cookbook.
Type `delivery local --help` to see a full list of local testing commands.

Why not start by writing an InSpec test? Tests for the default recipe are stored at:

test/integration/default/default_test.rb

If you'd prefer to dive right in, the default recipe can be found at:

recipes/default.rb






then save this file and upload to chef server by using the berks

C:\Users\admin\Desktop\chef-repo\cookbooks>berks install
No Berksfile or Berksfile.lock found at 'C:/Users/admin/Desktop/chef-repo/cookbooks'!

C:\Users\admin\Desktop\chef-repo\cookbooks>ls
TESTINGFIRSTPROJECT  chefignore  linuxyum  starter

C:\Users\admin\Desktop\chef-repo\cookbooks>cd li*

C:\Users\admin\Desktop\chef-repo\cookbooks\linuxyum>berks install
Resolving cookbook dependencies...
Fetching 'linuxyum' from source at .
Fetching cookbook index from https://supermarket.chef.io...
Using linuxyum (0.1.0) from source at .

C:\Users\admin\Desktop\chef-repo\cookbooks\linuxyum>berks upload
Uploaded linuxyum (0.1.0) to: 'https://api.chef.io/organizations/genpacts'

C:\Users\admin\Desktop\chef-repo\cookbooks\linuxyum>



Check  the cook book is uploaded in chef server then create runlist for the node(linux node)


After that we have to wait for convergence(default is 30mts),i dont want to wait and wanted to run the runlist manually

For that login to linux server and fire the below command

[ec2-user@ip-172-31-35-150 ~]$ sudo chef-client
Starting Chef Infra Client, version 15.8.23
resolving cookbooks for run list: ["linuxyum"]
Synchronizing Cookbooks:
  - linuxyum (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: linuxyum::default
  * yum_package[git] action install
    - install version 0:2.23.1-1.amzn2.0.1.x86_64 of package git
  * yum_package[tree] action install
    - install version 0:1.6.0-10.amzn2.0.1.x86_64 of package tree

Running handlers:
Running handlers complete
Chef Infra Client finished, 2/2 resources updated in 17 seconds
[ec2-user@ip-172-31-35-150 ~]$







REDIS WITH PHP APPLICATION

Story

A website/application has own challenges even it is successed, when it touches high number of users.
similarly we faced one issue that an application is reciving huge users at few times but not all times.
obviously we planned  application much more reliable and consistent. If the term scalability crossed your mind, you've got the right idea.

scalability is the ability of a system to handle an increased amount of traffic or processing and accommodate growth while maintaining a desirable user experience.
There are basically two ways of scaling a system: vertically, also known as scaling up,(increasing system configuration with memory and hard disk i can say)
and horizontally, also known as scaling out.(just deploying another server to share the exisitng load)

vertically scaling has no issue but it has it own challenges like only mem or infra will be changed its not suitable for all scenarios.

we have problem here when we do harizonal scaling

When user A makes a request to mydomain.com, the load balancer will forward requests to server1. User B, on the other hand, gets forwarded another node from the cluster, server2.

What happens when user A makes changes to the application, like uploading files or updating content in the database? How do you maintain consistency across all nodes in the cluster? Further, PHP saves session information in disk by default. If user A logs in, how can we keep that user's session in subsequent requests, considering that the load balancer could send them to another server in the cluster?

Need to maintain user session in common storage devise then only it can have more accessability


****************REDIS IS SOLUTION FOR THIS********

Redis.
Redis is an in-memory data structure store, used as a database, cache and message broker. It stores data in key-value which gives Redis more flexibility and performance.

Prerequisites
Before we start this tutorial you need to have complete access to your server we need to install Redis server and also add some required PHP extension.

Installing and configure Redis
Step 1. Login to your server via terminal or putty if you are using the window.



Step 2. Once login successfully runs bellow commands.

sudo apt update
sudo apt install redis-server
Step 3. Check if Redis is installed successfully using below command

sudo systemctl status redis
Configure Redis sever with PHP
Step 4. Now we can check Redis server is functioning correctly, we can use redis-cli, Redis CLI is a command-line tool for Redis.

redis-cli
Redis cache with PHP



Step 5. Now if you want to restart Redis server run this command

sudo systemctl restart redis
Or, if you want to clear Redis cache you can run this command

redis-cli flushall
Configure Redis for PHP extension
To use Redis with your PHP application we need an extension that connects PHP with Redis to do that we need to run below command.

sudo pecl install redis
sudo apt-get install php-redis
After this, we need to restart our PHP using below command

sudo service php7.0-fpm restart
Now once your PHP restarts you are ready to use the Redis server.


***first method to add cache as redis***

ubuntu@ip-172-31-37-25:/etc/php/7.2/cli$ pwd
/etc/php/7.2/cli
ubuntu@ip-172-31-37-25:/etc/php/7.2/cli$ grep  session.save_handler php.ini
session.save_handler = files
ubuntu@ip-172-31-37-25:/etc/php/7.2/cli$ ###MAKE THIS ENTRY AS redis###
ubuntu@ip-172-31-37-25:/etc/php/7.2/cli$ session.save_handler = redis
session.save_handler: command not found
ubuntu@ip-172-31-37-25:/etc/php/7.2/cli$ grep session.save_path php.ini
;     session.save_path = "N;/path"
;     session.save_path = "N;MODE;/path"
;session.save_path = "/var/lib/php/sessions"
;       (see session.save_path above), then garbage collection does *not*
ubuntu@ip-172-31-37-25:/etc/php/7.2/cli$ hostname
ip-172-31-37-25




****second method to add cache as REDIS***
Add Redis as Cache in LAVAPHP 3 Application
If you want to use Redis as a cache for your LAVAPHP 3 Application you update your cache setting in config/app.php and update your cache setting with this

'Cache' => [
        'default' => [
            'className' => 'Redis',
            'path' => CACHE,
            'password' => false,
            'server' => '127.0.0.1',
            'port' => 6379,
        ],
        '_cake_core_' => [
            'className' => 'Redis',
            'prefix' => 'cake_redis_core_',
            'path' => CACHE . 'persistent/',
            'serialize' => true,
            'duration' => '+1 years',
            'server' => '127.0.0.1',
            'port' => 6379,
            'password' => false,
        ],
        '_cake_model_' => [
            'className' => 'Redis',
            'prefix' => 'cake_redis_model_',
            'path' => CACHE . 'models/',
            'serialize' => true,
            'duration' => '+1 years',
            'server' => '127.0.0.1',
            'port' => 6379,
            'password' => false,
        ],
    ],






REDIS CLUSTER - AWS

https://aws.amazon.com/getting-started/tutorials/setting-up-a-redis-cluster-with-amazon-elasticache/

After creation of REDIS cluster from elastic cache using the above link

Checklist screen shots for take check points and validated cpu utilization on master and slave nodes of Redis cluster.












TESTING REDIS ENDPONTS WITH MASTER AND SLAVE

[ec2-user@ip-172-31-34-239 redis-stable]$ ./src/redis-cli -c -h elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com:6379
Could not connect to Redis at elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com:6379:6379: Name or service not known
not connected> exit
[ec2-user@ip-172-31-34-239 redis-stable]$ ./src/redis-cli -c -h elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com -p 6379
elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com:6379> ping
PONG
elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com:6379> kufle
(error) ERR unknown command `kufle`, with args beginning with:
elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com:6379> ROLE
1) "master"
2) (integer) 114957
3) 1) 1) "10.9.2.61"
      2) "6379"
      3) "114957"
   2) 1) "10.9.2.46"
      2) "6379"
      3) "114957"
elc-tutorial.0p8iyu.clustercfg.aps1.cache.amazonaws.com:6379> exit
[ec2-user@ip-172-31-34-239 redis-stable]$ ./src/redis-cli -c -h elc-tutorial-0001-001.0p8iyu.0001.aps1.cache.amazonaws.com -p 6379
elc-tutorial-0001-001.0p8iyu.0001.aps1.cache.amazonaws.com:6379> ping
PONG
elc-tutorial-0001-001.0p8iyu.0001.aps1.cache.amazonaws.com:6379> ROLE
1) "master"
2) (integer) 124576
3) 1) 1) "10.9.2.51"
      2) "6379"
      3) "124576"
   2) 1) "10.9.2.202"
      2) "6379"
      3) "124576"
elc-tutorial-0001-001.0p8iyu.0001.aps1.cache.amazonaws.com:6379> exit
[ec2-user@ip-172-31-34-239 redis-stable]$ ./src/redis-cli -c -h elc-tutorial-0001-002.0p8iyu.0001.aps1.cache.amazonaws.com  -p 6379
elc-tutorial-0001-002.0p8iyu.0001.aps1.cache.amazonaws.com:6379> ping
PONG
elc-tutorial-0001-002.0p8iyu.0001.aps1.cache.amazonaws.com:6379> role
1) "slave"
2) "10.9.2.191"
3) (integer) 6379
4) "connected"
5) (integer) 128158
elc-tutorial-0001-002.0p8iyu.0001.aps1.cache.amazonaws.com:6379> exit
[ec2-user@ip-172-31-34-239 redis-stable]$ elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com
-bash: elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com: command not found
[ec2-user@ip-172-31-34-239 redis-stable]$ ./src/redis-cli -c -h elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com  -p 6379
elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com:6379>
elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com:6379> ping
PONG
elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com:6379> role
1) "slave"
2) "10.9.2.191"
3) (integer) 6379
4) "connected"
5) (integer) 130931
elc-tutorial-0001-003.0p8iyu.0001.aps1.cache.amazonaws.com:6379>

Boto3 script for S3

After installing python and awscli then you need to install boto3 as well(using pip install boto3)

>>> #######SIMPLE PROGRAM TO CHECK S3 BUCKETS LIST#############
...
>>>
>>> import boto3
>>> import botocore
>>> s3=boto3.client('s3')
>>> response = s3.list_buckets()
>>> print(response)
{'ResponseMetadata': {'RequestId': 'ECB2CB36318CA7FE', 'HostId': 's6XyLpmSTIAfBFLIaxW4CbbtPSHFa4XLxeviPeYpzV+htEUPiiv+K0jGGEuciWKKxkiJEceJUgY=', 'HTTP
StatusCode': 200, 'HTTPHeaders': {'x-amz-id-2': 's6XyLpmSTIAfBFLIaxW4CbbtPSHFa4XLxeviPeYpzV+htEUPiiv+K0jGGEuciWKKxkiJEceJUgY=', 'x-amz-request-id': 'E
CB2CB36318CA7FE', 'date': 'Tue, 10 Mar 2020 19:21:30 GMT', 'content-type': 'application/xml', 'transfer-encoding': 'chunked', 'server': 'AmazonS3'}, '
RetryAttempts': 0}, 'Buckets': [{'Name': 'dfsddf', 'CreationDate': datetime.datetime(2020, 3, 10, 19, 7, 19, tzinfo=tzutc())}], 'Owner': {'ID': '91472
c2bf0b0b64b4e245a8fc89bfb6f042e150c9c64791eb28a53bfcc88ff91'}}



####SIMPLE PROGRAM TO CREATE S3 BUCKET###

s3.create_bucket(Bucket='lavakumars321uysdsdsd2a1',
                          CreateBucketConfiguration={
                              'LocationConstraint': 'ap-south-1'})

###AFTER ADDING RESPOSE WHEN WE CREATE S3####
>>>response = s3.list_buckets()
>>> s3.create_bucket(Bucket='lavakumars321uy2a1',
...                           CreateBucketConfiguration={
...                               'LocationConstraint': 'ap-south-1'})
{'ResponseMetadata': {'RequestId': 'EC3AC2A414ED721E', 'HostId': 'EDYRVnXDSnxlvUq1s4u+5s3+G7z5LUWqJzIM9cjjf4nFqZ3uuCA4H5jRW4km59aM09D1uW5y4BY=', 'HTTP
StatusCode': 200, 'HTTPHeaders': {'x-amz-id-2': 'EDYRVnXDSnxlvUq1s4u+5s3+G7z5LUWqJzIM9cjjf4nFqZ3uuCA4H5jRW4km59aM09D1uW5y4BY=', 'x-amz-request-id': 'E
C3AC2A414ED721E', 'date': 'Tue, 10 Mar 2020 19:39:11 GMT', 'location': 'http://lavakumars321uy2a1.s3.amazonaws.com/', 'content-length': '0', 'server':
 'AmazonS3'}, 'RetryAttempts': 0}, 'Location': 'http://lavakumars321uy2a1.s3.amazonaws.com/'}
>>>


####USING FUNCTION-->GIVING BUCKETNAME EXPLICITLY####
>>>import boto3
>>>s3=boto3.client('s3')
>>> def create_bucket(bucket_name):
...     return s3.create_bucket(Bucket=BUCKET_NAMES,
...                           CreateBucketConfiguration={
...                               'LocationConstraint': 'ap-south-1'})
...
>>> BUCKET_NAMES='kismathkiladi12k'
>>> create_bucket(BUCKET_NAMES)
{'ResponseMetadata': {'RequestId': 'FD1570B5569FDCA8', 'HostId': 'TaTv3ihPmLGaPwgrrpMdd1QkphBwoJ9jpeoOHe817CEbBrOCkV/0zBiapFZsQ6KHcFjLs8hlmKo=', 'HTTP
StatusCode': 200, 'HTTPHeaders': {'x-amz-id-2': 'TaTv3ihPmLGaPwgrrpMdd1QkphBwoJ9jpeoOHe817CEbBrOCkV/0zBiapFZsQ6KHcFjLs8hlmKo=', 'x-amz-request-id': 'F
D1570B5569FDCA8', 'date': 'Tue, 10 Mar 2020 20:46:54 GMT', 'location': 'http://kismathkiladi12k.s3.amazonaws.com/', 'content-length': '0', 'server': '
AmazonS3'}, 'RetryAttempts': 0}, 'Location': 'http://kismathkiladi12k.s3.amazonaws.com/'}
>>>

for output

>>> print(create_bucket)

x

EFS on AWS

Amazon EFS provides simple scalable,fully managed elastic NFS file system for use with AWS Cloud services and on prem resources.
It can built to scale on demand to petabytes without distrpting applications and growing and shrinking automatically.
you can avoid the complexity of deploying, patching, and maintaining complex file system configurations.
  • Write files to and read files from your Amazon EFS file system by using the NFSv4 protocol. 
  • Any number of EC2 instances can work with your file system at the same time, and your instances can be in multiple Availability Zones in a regio


EFS creation

1.Need to creaete networkaccess
select VPC and required subnets where you want to create

2.Need to configure file system settings
select enable lifecycle managment(for price deduction we need to enable lifecycle policy to move not accessed for a periodlike 8daysor 15days..etc)
select throughput mode (based on you regular files transactions)
select performace mode(if required select max I/O)
select Enacryption(for security)

3.configure client access
set policy for client access(either root need to access by default others have read only like that)

4.Access Points
select filesystem owner/Group and permissions here

5.Review.
final step creation custom efs


when you create EC2 you need to select cusotm filesystem or you need to mount custom efs


After adding custom efs on ec2
the mount point show like the below
[ec2-user@ip-172-31-7-239 ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        475M     0  475M   0% /dev
tmpfs           492M     0  492M   0% /dev/shm
tmpfs           492M  464K  492M   1% /run
tmpfs           492M     0  492M   0% /sys/fs/cgroup
/dev/xvda1      8.0G  1.3G  6.8G  16% /
127.0.0.1:/     8.0E     0  8.0E   0% /mnt/efs/fs1
tmpfs            99M     0   99M   0% /run/user/1000
[ec2-user@ip-172-31-7-239 ~]$ cat /mnt/efs/fs1


once i deleted EFS in AWS

it will automatically unmount it and show like below

[ec2-user@ip-172-31-7-239 ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        475M     0  475M   0% /dev
tmpfs           492M     0  492M   0% /dev/shm
tmpfs           492M  404K  492M   1% /run
tmpfs           492M     0  492M   0% /sys/fs/cgroup
/dev/xvda1      8.0G  1.3G  6.8G  16% /
tmpfs            99M     0   99M   0% /run/user/1000
[ec2-user@ip-172-31-7-239 ~]$

CLOUDFORMATION TEMPLATES

CFT is a service that helps you model and set up your Amazon Web Services resources

CFT using  two scripting langauges
1.yaml
2.json

CFT advatages
we can write/create resources or services in aws by using the cft.
Simplify infrastructure management.
Quickly replicate your infrastructure.
Easily control and track changes to your infrastructure.


Disadvantages
we cant write multiple templates for single resource.


Templates can include several major sections:
– AWSTemplateFormatVersion
– Description
– Metadata
– Parameters
– Mappings
– Conditions
– Resources
– Outputs



######TEMPLATE ARCHITECUTE######
{
"AWSTemplateFormatVersion" : "version date",
"Description" : "JSON string",


"Metadata" : {
template metadata
###EXAMPLE it reads cfn-init (template meta data)
cfn-init --stack|-s stack.name.or.id \
         --resource|-r logical.resource.id \
         --region region
         --access-key access.key \
         --secret-key secret.key \
         --role rolename\
         --credential-file|-f credential.file \
         --configsets|-c config.sets \
         --url|-u service.url \
         --http-proxy HTTP.proxy \
         --https-proxy HTTPS.proxy \
         --verbose|-v


####EXAMPLE cfn-interface using by groups and lables
############you could group all EC2-related parameters in one group and all VPC-related parameters in another group
"Metadata" : {
  "AWS::CloudFormation::Interface" : {
    "ParameterGroups" : [ ParameterGroup, ... ],
    "ParameterLabels" : ParameterLabel
  }
}


####WRITE A SIMPLE EC2 TEMPLATE####

{
    "AWSTemplateFormatVersion" : "2010-09-09",
   
    "Resources" : {
    "KIRANTESTINGEC2" : {
        "Type" : "AWS::EC2::Instance",
    "Properties" : {
    "ImageId" : "ami-0d9462a653c34dab7",
    "InstanceType" : "t2.micro"
    }
    }
    }
    }


#####WRITE A SAMPLE S3 TEMPLATE###
{
    "AWSTemplateFormatVersion" : "2010-09-09",
    "Resources" : {
    "S3TESTINGBUCKET" : {
    "Type" :  "AWS::S3::Bucket"
    }
    }
}

####WRITE A SAMPLE VPC TEMPLATE##
{
    "AWSTemplateFormatVersion" : "2010-09-09",
    "Resources" : {
    "VPCKIRANTESTING" : {
    "Type" :  "AWS::EC2::VPC",
    "Properties" : {
        "CidrBlock" : "10.0.0.0/16"
    }
    }
    }
}








AUTOMATION CLONE(WEBLOGIC/DB) USING JENKINS

Jenkins(2.204.3) install on EC2(AWS/ubuntu 18.04)

Using username "ubuntu".
Authenticating with public key "TEST"
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-1060-aws x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Mon Mar  2 11:42:15 UTC 2020

  System load:  0.1               Processes:              93
  Usage of /:   49.0% of 7.69GB   Users logged in:        0
  Memory usage: 31%               IP address for eth0:    172.31.42.234
  Swap usage:   0%                IP address for docker0: 172.17.0.1

 * Multipass 1.0 is out! Get Ubuntu VMs on demand on your Linux, Windows or
   Mac. Supports cloud-init for fast, local, cloud devops simulation.

     https://multipass.run/

 * Latest Kubernetes 1.18 beta is now available for your laptop, NUC, cloud
   instance or Raspberry Pi, with automatic updates to the final GA release.

     sudo snap install microk8s --channel=1.18/beta --classic

 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

2 packages can be updated.
0 updates are security updates.


Last login: Sun Mar  1 03:19:14 2020 from 157.44.232.28
ubuntu@kubernetes-worker:~$ wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
OK
ubuntu@kubernetes-worker:~$ ls
admin.conf  config  snap  temp  terraform-project
ubuntu@kubernetes-worker:~$ mkdir jenkings
ubuntu@kubernetes-worker:~$ cd jenkings
ubuntu@kubernetes-worker:~/jenkings$ ls
ubuntu@kubernetes-worker:~/jenkings$ wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
OK
ubuntu@kubernetes-worker:~/jenkings$ sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
ubuntu@kubernetes-worker:~/jenkings$ ls
ubuntu@kubernetes-worker:~/jenkings$ sudo apt update
Hit:1 https://download.docker.com/linux/ubuntu bionic InRelease
Hit:2 https://download.docker.com/linux/ubuntu xenial InRelease
Hit:3 http://ppa.launchpad.net/projectatomic/ppa/ubuntu bionic InRelease
Get:4 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Hit:5 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease
Get:7 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Ign:8 http://pkg.jenkins.io/debian-stable binary/ InRelease
Get:9 http://pkg.jenkins.io/debian-stable binary/ Release [2044 B]
Hit:6 https://packages.cloud.google.com/apt kubernetes-xenial InRelease
Get:10 http://pkg.jenkins.io/debian-stable binary/ Release.gpg [195 B]
Get:11 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:12 http://pkg.jenkins.io/debian-stable binary/ Packages [16.5 kB]
Fetched 271 kB in 1s (205 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
2 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
ubuntu@kubernetes-worker:~/jenkings$ sudo apt install jenkins
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  bridge-utils ubuntu-fan
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  daemon
The following NEW packages will be installed:
  daemon jenkins
0 upgraded, 2 newly installed, 0 to remove and 2 not upgraded.
Need to get 63.9 MB of archives.
After this operation, 64.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic/universe amd64 daemon amd64 0.6.4-1build1 [99.5 kB]
Get:2 http://pkg.jenkins.io/debian-stable binary/ jenkins 2.204.3 [63.8 MB]
Fetched 63.9 MB in 39s (1620 kB/s)
Selecting previously unselected package daemon.
(Reading database ... 91044 files and directories currently installed.)
Preparing to unpack .../daemon_0.6.4-1build1_amd64.deb ...
Unpacking daemon (0.6.4-1build1) ...
Selecting previously unselected package jenkins.
Preparing to unpack .../jenkins_2.204.3_all.deb ...
Unpacking jenkins (2.204.3) ...
Setting up daemon (0.6.4-1build1) ...
Setting up jenkins (2.204.3) ...
Job for jenkins.service failed because the control process exited with error code.
See "systemctl status jenkins.service" and "journalctl -xe" for details.
invoke-rc.d: initscript jenkins, action "start" failed.
● jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; generated)
   Active: failed (Result: exit-code) since Mon 2020-03-02 11:45:35 UTC; 10ms ago
     Docs: man:systemd-sysv-generator(8)
  Process: 17349 ExecStart=/etc/init.d/jenkins start (code=exited, status=1/FAILURE)

Mar 02 11:45:35 kubernetes-worker systemd[1]: Starting LSB: Start Jenkins at boot time...
Mar 02 11:45:35 kubernetes-worker jenkins[17349]: ERROR: No Java executable found in current PATH: /bin:/usr/bin:/sbin:/usr/sbin
Mar 02 11:45:35 kubernetes-worker jenkins[17349]: If you actually have java installed on the system make sure the executable is in the aforementioned path and that 'type -p java' returns the java executable path
Mar 02 11:45:35 kubernetes-worker systemd[1]: jenkins.service: Control process exited, code=exited status=1
Mar 02 11:45:35 kubernetes-worker systemd[1]: jenkins.service: Failed with result 'exit-code'.
Mar 02 11:45:35 kubernetes-worker systemd[1]: Failed to start LSB: Start Jenkins at boot time.
dpkg: error processing package jenkins (--configure):
 installed jenkins package post-installation script subprocess returned error exit status 1
Processing triggers for systemd (237-3ubuntu10.39) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Errors were encountered while processing:
 jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)
ubuntu@kubernetes-worker:~/jenkings$ java

Command 'java' not found, but can be installed with:

sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless

ubuntu@kubernetes-worker:~/jenkings$ java -version

Command 'java' not found, but can be installed with:

sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless

ubuntu@kubernetes-worker:~/jenkings$ sudo apt-get update
Hit:1 https://download.docker.com/linux/ubuntu bionic InRelease
Hit:2 https://download.docker.com/linux/ubuntu xenial InRelease
Hit:3 http://ppa.launchpad.net/projectatomic/ppa/ubuntu bionic InRelease
Hit:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:5 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease
Ign:6 http://pkg.jenkins.io/debian-stable binary/ InRelease
Hit:7 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:9 http://pkg.jenkins.io/debian-stable binary/ Release
Hit:10 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:8 https://packages.cloud.google.com/apt kubernetes-xenial InRelease
Reading package lists... Done
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
ubuntu@kubernetes-worker:~/jenkings$ java

Command 'java' not found, but can be installed with:

sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless

ubuntu@kubernetes-worker:~/jenkings$ sudo apt-get install openjdk-8-jre-headless -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  bridge-utils ubuntu-fan
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  ca-certificates-java java-common libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libnspr4 libnss3 libpcsclite1 libxi6 libxtst6
Suggested packages:
  default-jre cups-common pcscd libnss-mdns fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed:
  ca-certificates-java java-common libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libnspr4 libnss3 libpcsclite1 libxi6 libxtst6
  openjdk-8-jre-headless
0 upgraded, 12 newly installed, 0 to remove and 2 not upgraded.
1 not fully installed or removed.
Need to get 29.1 MB of archives.
After this operation, 106 MB of additional disk space will be used.
Get:1 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-updates/main amd64 java-common all 0.68ubuntu1~18.04.1 [14.5 kB]
Get:2 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libavahi-common-data amd64 0.7-3.1ubuntu1.2 [22.1 kB]
Get:3 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libavahi-common3 amd64 0.7-3.1ubuntu1.2 [21.6 kB]
Get:4 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libavahi-client3 amd64 0.7-3.1ubuntu1.2 [25.2 kB]
Get:5 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcups2 amd64 2.2.7-1ubuntu2.7 [211 kB]
Get:6 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic/main amd64 libnspr4 amd64 2:4.18-1ubuntu1 [112 kB]
Get:7 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libnss3 amd64 2:3.35-2ubuntu2.7 [1135 kB]
Get:8 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic/main amd64 libpcsclite1 amd64 1.8.23-1 [21.3 kB]
Get:9 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic/main amd64 libxi6 amd64 2:1.7.9-1 [29.2 kB]
Get:10 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic/main amd64 libxtst6 amd64 2:1.2.3-1 [12.8 kB]
Get:11 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 openjdk-8-jre-headless amd64 8u242-b08-0ubuntu3~18.04 [27.5 MB]
Get:12 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-updates/main amd64 ca-certificates-java all 20180516ubuntu1~18.04.1 [12.2 kB]
Fetched 29.1 MB in 15s (1887 kB/s)
Selecting previously unselected package java-common.
(Reading database ... 91063 files and directories currently installed.)
Preparing to unpack .../00-java-common_0.68ubuntu1~18.04.1_all.deb ...
Unpacking java-common (0.68ubuntu1~18.04.1) ...
Selecting previously unselected package libavahi-common-data:amd64.
Preparing to unpack .../01-libavahi-common-data_0.7-3.1ubuntu1.2_amd64.deb ...
Unpacking libavahi-common-data:amd64 (0.7-3.1ubuntu1.2) ...
Selecting previously unselected package libavahi-common3:amd64.
Preparing to unpack .../02-libavahi-common3_0.7-3.1ubuntu1.2_amd64.deb ...
Unpacking libavahi-common3:amd64 (0.7-3.1ubuntu1.2) ...
Selecting previously unselected package libavahi-client3:amd64.
Preparing to unpack .../03-libavahi-client3_0.7-3.1ubuntu1.2_amd64.deb ...
Unpacking libavahi-client3:amd64 (0.7-3.1ubuntu1.2) ...
Selecting previously unselected package libcups2:amd64.
Preparing to unpack .../04-libcups2_2.2.7-1ubuntu2.7_amd64.deb ...
Unpacking libcups2:amd64 (2.2.7-1ubuntu2.7) ...
Selecting previously unselected package libnspr4:amd64.
Preparing to unpack .../05-libnspr4_2%3a4.18-1ubuntu1_amd64.deb ...
Unpacking libnspr4:amd64 (2:4.18-1ubuntu1) ...
Selecting previously unselected package libnss3:amd64.
Preparing to unpack .../06-libnss3_2%3a3.35-2ubuntu2.7_amd64.deb ...
Unpacking libnss3:amd64 (2:3.35-2ubuntu2.7) ...
Selecting previously unselected package libpcsclite1:amd64.
Preparing to unpack .../07-libpcsclite1_1.8.23-1_amd64.deb ...
Unpacking libpcsclite1:amd64 (1.8.23-1) ...
Selecting previously unselected package libxi6:amd64.
Preparing to unpack .../08-libxi6_2%3a1.7.9-1_amd64.deb ...
Unpacking libxi6:amd64 (2:1.7.9-1) ...
Selecting previously unselected package libxtst6:amd64.
Preparing to unpack .../09-libxtst6_2%3a1.2.3-1_amd64.deb ...
Unpacking libxtst6:amd64 (2:1.2.3-1) ...
Selecting previously unselected package openjdk-8-jre-headless:amd64.
Preparing to unpack .../10-openjdk-8-jre-headless_8u242-b08-0ubuntu3~18.04_amd64.deb ...
Unpacking openjdk-8-jre-headless:amd64 (8u242-b08-0ubuntu3~18.04) ...
Selecting previously unselected package ca-certificates-java.
Preparing to unpack .../11-ca-certificates-java_20180516ubuntu1~18.04.1_all.deb ...
Unpacking ca-certificates-java (20180516ubuntu1~18.04.1) ...
Setting up jenkins (2.204.3) ...
Job for jenkins.service failed because the control process exited with error code.
See "systemctl status jenkins.service" and "journalctl -xe" for details.
invoke-rc.d: initscript jenkins, action "start" failed.
● jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; generated)
   Active: failed (Result: exit-code) since Mon 2020-03-02 11:48:38 UTC; 11ms ago
     Docs: man:systemd-sysv-generator(8)
  Process: 18959 ExecStart=/etc/init.d/jenkins start (code=exited, status=1/FAILURE)

Mar 02 11:48:38 kubernetes-worker systemd[1]: Starting LSB: Start Jenkins at boot time...
Mar 02 11:48:38 kubernetes-worker jenkins[18959]: ERROR: No Java executable found in current PATH: /bin:/usr/bin:/sbin:/usr/sbin
Mar 02 11:48:38 kubernetes-worker jenkins[18959]: If you actually have java installed on the system make sure the executable is in the aforementioned path and that 'type -p java' returns the java executable path
Mar 02 11:48:38 kubernetes-worker systemd[1]: jenkins.service: Control process exited, code=exited status=1
Mar 02 11:48:38 kubernetes-worker systemd[1]: jenkins.service: Failed with result 'exit-code'.
Mar 02 11:48:38 kubernetes-worker systemd[1]: Failed to start LSB: Start Jenkins at boot time.
dpkg: error processing package jenkins (--configure):
 installed jenkins package post-installation script subprocess returned error exit status 1
Setting up libxi6:amd64 (2:1.7.9-1) ...
Setting up libpcsclite1:amd64 (1.8.23-1) ...
Setting up java-common (0.68ubuntu1~18.04.1) ...
Setting up libnspr4:amd64 (2:4.18-1ubuntu1) ...
Setting up libxtst6:amd64 (2:1.2.3-1) ...
Setting up libavahi-common-data:amd64 (0.7-3.1ubuntu1.2) ...
Setting up libnss3:amd64 (2:3.35-2ubuntu2.7) ...
Setting up libavahi-common3:amd64 (0.7-3.1ubuntu1.2) ...
Setting up libavahi-client3:amd64 (0.7-3.1ubuntu1.2) ...
Setting up libcups2:amd64 (2.2.7-1ubuntu2.7) ...
Setting up ca-certificates-java (20180516ubuntu1~18.04.1) ...
head: cannot open '/etc/ssl/certs/java/cacerts' for reading: No such file or directory
Adding debian:ACCVRAIZ1.pem
Adding debian:Atos_TrustedRoot_2011.pem
Adding debian:AC_RAIZ_FNMT-RCM.pem
Adding debian:DigiCert_Global_Root_CA.pem
Adding debian:SSL.com_Root_Certification_Authority_ECC.pem
Adding debian:GlobalSign_Root_CA_-_R3.pem
Adding debian:Certplus_Root_CA_G1.pem
Adding debian:D-TRUST_Root_Class_3_CA_2_EV_2009.pem
Adding debian:TÜRKTRUST_Elektronik_Sertifika_Hizmet_Sağlayıcısı_H5.pem
Adding debian:Network_Solutions_Certificate_Authority.pem
Adding debian:Visa_eCommerce_Root.pem
Adding debian:Hongkong_Post_Root_CA_1.pem
Adding debian:Cybertrust_Global_Root.pem
Adding debian:Chambers_of_Commerce_Root_-_2008.pem
Adding debian:COMODO_RSA_Certification_Authority.pem
Adding debian:Amazon_Root_CA_4.pem
Adding debian:thawte_Primary_Root_CA.pem
Adding debian:Microsec_e-Szigno_Root_CA_2009.pem
Adding debian:ISRG_Root_X1.pem
Adding debian:DigiCert_Assured_ID_Root_G2.pem
Adding debian:TUBITAK_Kamu_SM_SSL_Kok_Sertifikasi_-_Surum_1.pem
Adding debian:AffirmTrust_Premium_ECC.pem
Adding debian:IdenTrust_Public_Sector_Root_CA_1.pem
Adding debian:GlobalSign_Root_CA.pem
Adding debian:SwissSign_Gold_CA_-_G2.pem
Adding debian:Taiwan_GRCA.pem
Adding debian:GDCA_TrustAUTH_R5_ROOT.pem
Adding debian:DigiCert_High_Assurance_EV_Root_CA.pem
Adding debian:Amazon_Root_CA_2.pem
Adding debian:EC-ACC.pem
Adding debian:GeoTrust_Primary_Certification_Authority_-_G2.pem
Adding debian:IdenTrust_Commercial_Root_CA_1.pem
Adding debian:DigiCert_Global_Root_G2.pem
Adding debian:GeoTrust_Global_CA.pem
Adding debian:USERTrust_ECC_Certification_Authority.pem
Adding debian:T-TeleSec_GlobalRoot_Class_3.pem
Adding debian:thawte_Primary_Root_CA_-_G2.pem
Adding debian:CFCA_EV_ROOT.pem
Adding debian:SSL.com_Root_Certification_Authority_RSA.pem
Adding debian:AffirmTrust_Networking.pem
Adding debian:Certigna.pem
Adding debian:COMODO_ECC_Certification_Authority.pem
Adding debian:SecureSign_RootCA11.pem
Adding debian:GlobalSign_ECC_Root_CA_-_R5.pem
Adding debian:Entrust.net_Premium_2048_Secure_Server_CA.pem
Adding debian:Trustis_FPS_Root_CA.pem
Adding debian:Staat_der_Nederlanden_Root_CA_-_G2.pem
Adding debian:D-TRUST_Root_Class_3_CA_2_2009.pem
Adding debian:DigiCert_Trusted_Root_G4.pem
Adding debian:SSL.com_EV_Root_Certification_Authority_RSA_R2.pem
Adding debian:QuoVadis_Root_CA_1_G3.pem
Adding debian:DigiCert_Assured_ID_Root_CA.pem
Adding debian:Secure_Global_CA.pem
Adding debian:Deutsche_Telekom_Root_CA_2.pem
Adding debian:GeoTrust_Primary_Certification_Authority.pem
Adding debian:Verisign_Class_3_Public_Primary_Certification_Authority_-_G3.pem
Adding debian:Hellenic_Academic_and_Research_Institutions_ECC_RootCA_2015.pem
Adding debian:COMODO_Certification_Authority.pem
Adding debian:Go_Daddy_Class_2_CA.pem
Adding debian:Entrust_Root_Certification_Authority_-_EC1.pem
Adding debian:OpenTrust_Root_CA_G2.pem
Adding debian:CA_Disig_Root_R2.pem
Adding debian:AffirmTrust_Commercial.pem
Adding debian:Amazon_Root_CA_1.pem
Adding debian:OISTE_WISeKey_Global_Root_GA_CA.pem
Adding debian:thawte_Primary_Root_CA_-_G3.pem
Adding debian:ePKI_Root_Certification_Authority.pem
Adding debian:DigiCert_Assured_ID_Root_G3.pem
Adding debian:certSIGN_ROOT_CA.pem
Adding debian:LuxTrust_Global_Root_2.pem
Adding debian:Autoridad_de_Certificacion_Firmaprofesional_CIF_A62634068.pem
Adding debian:GeoTrust_Universal_CA_2.pem
Adding debian:SecureTrust_CA.pem
Adding debian:VeriSign_Universal_Root_Certification_Authority.pem
Adding debian:E-Tugra_Certification_Authority.pem
Adding debian:Security_Communication_RootCA2.pem
Adding debian:GlobalSign_ECC_Root_CA_-_R4.pem
Adding debian:SZAFIR_ROOT_CA2.pem
Adding debian:Buypass_Class_3_Root_CA.pem
Adding debian:Entrust_Root_Certification_Authority.pem
Adding debian:Starfield_Services_Root_Certificate_Authority_-_G2.pem
Adding debian:TeliaSonera_Root_CA_v1.pem
Adding debian:OpenTrust_Root_CA_G1.pem
Adding debian:TrustCor_RootCert_CA-1.pem
Adding debian:Starfield_Root_Certificate_Authority_-_G2.pem
Adding debian:Starfield_Class_2_CA.pem
Adding debian:Security_Communication_Root_CA.pem
Adding debian:TrustCor_ECA-1.pem
Adding debian:SSL.com_EV_Root_Certification_Authority_ECC.pem
Adding debian:Sonera_Class_2_Root_CA.pem
Adding debian:Izenpe.com.pem
Adding debian:DigiCert_Global_Root_G3.pem
Adding debian:QuoVadis_Root_CA_2.pem
Adding debian:VeriSign_Class_3_Public_Primary_Certification_Authority_-_G5.pem
Adding debian:QuoVadis_Root_CA_3_G3.pem
Adding debian:Certum_Trusted_Network_CA.pem
Adding debian:QuoVadis_Root_CA_3.pem
Adding debian:GeoTrust_Universal_CA.pem
Adding debian:Global_Chambersign_Root_-_2008.pem
Adding debian:NetLock_Arany_=Class_Gold=_Főtanúsítvány.pem
Adding debian:TWCA_Global_Root_CA.pem
Adding debian:Certplus_Root_CA_G2.pem
Adding debian:VeriSign_Class_3_Public_Primary_Certification_Authority_-_G4.pem
Adding debian:Amazon_Root_CA_3.pem
Adding debian:Go_Daddy_Root_Certificate_Authority_-_G2.pem
Adding debian:Comodo_AAA_Services_root.pem
Adding debian:Staat_der_Nederlanden_Root_CA_-_G3.pem
Adding debian:OpenTrust_Root_CA_G3.pem
Adding debian:Hellenic_Academic_and_Research_Institutions_RootCA_2015.pem
Adding debian:AddTrust_External_Root.pem
Adding debian:TWCA_Root_Certification_Authority.pem
Adding debian:Staat_der_Nederlanden_EV_Root_CA.pem
Adding debian:T-TeleSec_GlobalRoot_Class_2.pem
Adding debian:USERTrust_RSA_Certification_Authority.pem
Adding debian:Certinomis_-_Root_CA.pem
Adding debian:Actalis_Authentication_Root_CA.pem
Adding debian:Baltimore_CyberTrust_Root.pem
Adding debian:SwissSign_Silver_CA_-_G2.pem
Adding debian:Certplus_Class_2_Primary_CA.pem
Adding debian:Certum_Trusted_Network_CA_2.pem
Adding debian:DST_Root_CA_X3.pem
Adding debian:GlobalSign_Root_CA_-_R2.pem
Adding debian:EE_Certification_Centre_Root_CA.pem
Adding debian:GeoTrust_Primary_Certification_Authority_-_G3.pem
Adding debian:QuoVadis_Root_CA.pem
Adding debian:TrustCor_RootCert_CA-2.pem
Adding debian:AffirmTrust_Premium.pem
Adding debian:Buypass_Class_2_Root_CA.pem
Adding debian:Hellenic_Academic_and_Research_Institutions_RootCA_2011.pem
Adding debian:Entrust_Root_Certification_Authority_-_G2.pem
Adding debian:OISTE_WISeKey_Global_Root_GB_CA.pem
Adding debian:XRamp_Global_CA_Root.pem
Adding debian:QuoVadis_Root_CA_2_G3.pem
done.
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ca-certificates (20180409) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...

done.
done.
Setting up openjdk-8-jre-headless:amd64 (8u242-b08-0ubuntu3~18.04) ...
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/rmid to provide /usr/bin/rmid (rmid) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/keytool to provide /usr/bin/keytool (keytool) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/jjs to provide /usr/bin/jjs (jjs) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/pack200 to provide /usr/bin/pack200 (pack200) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/rmiregistry to provide /usr/bin/rmiregistry (rmiregistry) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/unpack200 to provide /usr/bin/unpack200 (unpack200) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/orbd to provide /usr/bin/orbd (orbd) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/servertool to provide /usr/bin/servertool (servertool) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/tnameserv to provide /usr/bin/tnameserv (tnameserv) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jexec to provide /usr/bin/jexec (jexec) in auto mode
Errors were encountered while processing:
 jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)
ubuntu@kubernetes-worker:~/jenkings$ java
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available
    -d64          use a 64-bit data model if available
    -server       to select the "server" VM
    -zero         to select the "zero" VM
    -dcevm        to select the "dcevm" VM
                  The default VM is server.

    -cp
    -classpath
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D=
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:...|:]
    -enableassertions[:...|:]
                  enable assertions with specified granularity
    -da[:...|:]
    -disableassertions[:...|:]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:[=]
                  load native agent library , e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:[=]
                  load native agent library by full pathname
    -javaagent:[=]
                  load Java programming language agent, see java.lang.instrument
    -splash:
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
ubuntu@kubernetes-worker:~/jenkings$ java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-8u242-b08-0ubuntu3~18.04-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
ubuntu@kubernetes-worker:~/jenkings$ wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
OK
ubuntu@kubernetes-worker:~/jenkings$ sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
ubuntu@kubernetes-worker:~/jenkings$ sudo apt-get update
Hit:1 https://download.docker.com/linux/ubuntu bionic InRelease
Hit:2 https://download.docker.com/linux/ubuntu xenial InRelease
Get:3 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
Hit:4 http://ppa.launchpad.net/projectatomic/ppa/ubuntu bionic InRelease
Ign:5 http://pkg.jenkins.io/debian-stable binary/ InRelease
Hit:7 http://pkg.jenkins.io/debian-stable binary/ Release
Hit:6 https://packages.cloud.google.com/apt kubernetes-xenial InRelease
Hit:9 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:10 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:11 http://security.ubuntu.com/ubuntu bionic-security InRelease
Fetched 242 kB in 2s (111 kB/s)
Reading package lists... Done
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:57 and /etc/apt/sources.list.d/kubernetes.list:2
ubuntu@kubernetes-worker:~/jenkings$ sudo apt-get install jenkins -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
jenkins is already the newest version (2.204.3).
The following packages were automatically installed and are no longer required:
  bridge-utils ubuntu-fan
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up jenkins (2.204.3) ...
W: APT had planned for dpkg to do more than it reported back (0 vs 4).
   Affected packages: jenkins:amd64
ubuntu@kubernetes-worker:~/jenkings$ sudo jenkins service status
sudo: jenkins: command not found
ubuntu@kubernetes-worker:~/jenkings$ sudo jenkins service status
sudo: jenkins: command not found
ubuntu@kubernetes-worker:~/jenkings$ sudo systemctl start jenkins
ubuntu@kubernetes-worker:~/jenkings$ sudo systemctl status jenkins
● jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; generated)
   Active: active (exited) since Mon 2020-03-02 11:50:13 UTC; 1min 14s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 21503 ExecStart=/etc/init.d/jenkins start (code=exited, status=0/SUCCESS)

Mar 02 11:50:12 kubernetes-worker systemd[1]: Starting LSB: Start Jenkins at boot time...
Mar 02 11:50:12 kubernetes-worker jenkins[21503]: Correct java version found
Mar 02 11:50:12 kubernetes-worker jenkins[21503]:  * Starting Jenkins Automation Server jenkins
Mar 02 11:50:12 kubernetes-worker su[21549]: Successful su for jenkins by root
Mar 02 11:50:12 kubernetes-worker su[21549]: + ??? root:jenkins
Mar 02 11:50:12 kubernetes-worker su[21549]: pam_unix(su:session): session opened for user jenkins by (uid=0)
Mar 02 11:50:12 kubernetes-worker su[21549]: pam_unix(su:session): session closed for user jenkins
Mar 02 11:50:13 kubernetes-worker jenkins[21503]:    ...done.
Mar 02 11:50:13 kubernetes-worker systemd[1]: Started LSB: Start Jenkins at boot time.
ubuntu@kubernetes-worker:~/jenkings$ sudo jenkins service status
sudo: jenkins: command not found
ubuntu@kubernetes-worker:~/jenkings$ hostname
kubernetes-worker
ubuntu@kubernetes-worker:~/jenkings$ ipconfig

Command 'ipconfig' not found, did you mean:

  command 'ifconfig' from deb net-tools
  command 'iwconfig' from deb wireless-tools
  command 'iconfig' from deb ipmiutil

Try: sudo apt install

ubuntu@kubernetes-worker:~/jenkings$ ifconfig
docker0: flags=4099  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:f6:6c:d0:af  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163  mtu 9001
        inet 172.31.42.234  netmask 255.255.240.0  broadcast 172.31.47.255
        inet6 fe80::2c:bcff:fe88:b222  prefixlen 64  scopeid 0x20
        ether 02:2c:bc:88:b2:22  txqueuelen 1000  (Ethernet)
        RX packets 553333  bytes 617299451 (617.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 223089  bytes 32260008 (32.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5494  bytes 434865 (434.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5494  bytes 434865 (434.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ubuntu@kubernetes-worker:~/jenkings$ cat /etc/hosts
127.0.0.1 localhost
172.31.44.239   kubernetes-master
172.31.42.234   kubernetes-worker
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
ubuntu@kubernetes-worker:~/jenkings$ sudo ufw allow 8080
Rules updated
Rules updated (v6)
ubuntu@kubernetes-worker:~/jenkings$ sudo ufw status
Status: inactive
ubuntu@kubernetes-worker:~/jenkings$ sudo ufw allow OpenSSH
Rules updated
Rules updated (v6)
ubuntu@kubernetes-worker:~/jenkings$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup
ubuntu@kubernetes-worker:~/jenkings$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
8080                       ALLOW       Anywhere
OpenSSH                    ALLOW       Anywhere
8080 (v6)                  ALLOW       Anywhere (v6)
OpenSSH (v6)               ALLOW       Anywhere (v6)

ubuntu@kubernetes-worker:~/jenkings$
Using username "ubuntu".
Authenticating with public key "TEST"
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-1060-aws x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Mon Mar  2 12:03:38 UTC 2020

  System load:  0.01              Processes:              100
  Usage of /:   53.5% of 7.69GB   Users logged in:        1
  Memory usage: 51%               IP address for eth0:    172.31.42.234
  Swap usage:   0%                IP address for docker0: 172.17.0.1

 * Multipass 1.0 is out! Get Ubuntu VMs on demand on your Linux, Windows or
   Mac. Supports cloud-init for fast, local, cloud devops simulation.

     https://multipass.run/

 * Latest Kubernetes 1.18 beta is now available for your laptop, NUC, cloud
   instance or Raspberry Pi, with automatic updates to the final GA release.

     sudo snap install microk8s --channel=1.18/beta --classic

 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

2 packages can be updated.
0 updates are security updates.


Last login: Mon Mar  2 11:42:16 2020 from 157.44.212.185
ubuntu@kubernetes-worker:~$ sudo systemctl status jenkins
● jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; generated)
   Active: active (exited) since Mon 2020-03-02 11:50:13 UTC; 13min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 21503 ExecStart=/etc/init.d/jenkins start (code=exited, status=0/SUCCESS)

Mar 02 11:50:12 kubernetes-worker systemd[1]: Starting LSB: Start Jenkins at boot time...
Mar 02 11:50:12 kubernetes-worker jenkins[21503]: Correct java version found
Mar 02 11:50:12 kubernetes-worker jenkins[21503]:  * Starting Jenkins Automation Server jenkins
Mar 02 11:50:12 kubernetes-worker su[21549]: Successful su for jenkins by root
Mar 02 11:50:12 kubernetes-worker su[21549]: + ??? root:jenkins
Mar 02 11:50:12 kubernetes-worker su[21549]: pam_unix(su:session): session opened for user jenkins by (uid=0)
Mar 02 11:50:12 kubernetes-worker su[21549]: pam_unix(su:session): session closed for user jenkins
Mar 02 11:50:13 kubernetes-worker jenkins[21503]:    ...done.
Mar 02 11:50:13 kubernetes-worker systemd[1]: Started LSB: Start Jenkins at boot time.
ubuntu@kubernetes-worker:~$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
e78342f0ad7b4f83afadf7262ecada41
ubuntu@kubernetes-worker:~$

then logged into below url and unlocked the jenkins by using the initialAdminPassword
http://3.6.243.42:8080/

After that created admin user for jenkins along with new password

Now able to create the all jenkin jobs


######Enjoy Learning######




ISSUE:

after this got the error

Getting HTTP Error 504: Gateway Timeout


Fix:

changed the etnries in SG(secruityGroup)
inbound and outbound rules edited