Showing posts with label DevOps Troubleshooting. Show all posts
Showing posts with label DevOps Troubleshooting. Show all posts

Saturday, April 20, 2024

Fix for Jenkins slowness when Running in AWS EC2 instance | Jenkins Very Slow Upon Starting EC2 Instance after Stopping

Let's say that you have configured Jenkins in AWS EC2 instance and you are using AWS free tier and you are NOT using Elastic IP, so when ever you start EC2 instance after stopping, you would have noticed Jenkins UI is taking a lot of time to come up. You try to access any page in Jenkins, it will be really slow.

What is the root cause of the issue?

If you are using AWS free tier account and creating EC2 instance without using Elastic IP. If you are stopping EC2 instance and restarting EC2, this would have new IP after every restart, Jenkins was trying to use old IP address when you are trying to start Jenkins. Due to this issue, Jenkins will be very slow.

Pre-requisites:

  • Jenkins is setup in AWS cloud using free-tier account.

There are two ways you can fix this issue:

First option using command line

Make changes in the xml file by logging into EC2 instance through command line using Git bash or any SSH tool.

Connect to Jenkins EC2 instance using Git bash or iTerm:

Navigate to Jenkins installation directory:

cd /var/lib/jenkins/

Modify jenkins.model.JenkinsLocationConfiguration.xml file by executing below command:

sudo nano jenkins.model.JenkinsLocationConfiguration.xml

Make sure you provide Jenkins current URL in below location and restart Jenkins.

sudo service jenkins restart

Now try accessing Jenkins through UI, it will be really performing well.

Second option is using Jenkins UI

Change public URL under Manage Jenkins->System

Change Jenkins URL to current Jenkins URL:

Click on Apply-> Save.

that's it. You will notice Jenkins is performing well now.

Watch steps in YouTube channel:

Saturday, October 21, 2023

Fix for Kubernetes Deployment Error using helm chart | Error: kubernetes cluster unreachable: exec plugin: invalid apiversion "client.authentication.k8s.io/v1alpha1"

Error: kubernetes cluster unreachable: exec plugin: invalid apiversion "client.authentication.k8s.io/v1alpha1"

 

Root cause and fix:
Downgrading helm version to 3.8.2 would resolve the issue.

curl -L https://git.io/get_helm.sh | bash -s -- --version v3.8.2

Tuesday, April 4, 2023

SonarQube Server Cannot be reached Error Resolution | SonarQube Troubleshooting

How to Resolve SonarQube Server cannot be reached Error?

Pre-requisites:

Sonarqube was configured manually by downloading zip file. This instructions will not address for SonarQube that was configured by Docker compose.

Let's see how we can resolve the error:

Solution # 1
Your sonar.properties may not be setup correctly. It could be due to three different reasons: 1. verify below sonar.properties sudo vi /opt/sonarqube/conf/sonar.properties uncomment the below lines by removing # and add values highlighted yellow sonar.jdbc.username=sonar sonar.jdbc.password=password Next, uncomment the below line, removing # sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube
Solution # 2

Make sure you have setup Postgres SQL correctly.
2. Switch to sql shell by entering psql Execute the below lines (one by one) ALTER USER sonar WITH ENCRYPTED password 'password'; CREATE DATABASE sonarqube OWNER sonar; GRANT ALL PRIVILEGES ON DATABASE sonarqube to sonar; \q type exit tom come out of postgresSQL.
Solution #3
3. Make sure you have setup sonarqube as a service properly. Execute the below command: sudo vi /etc/systemd/system/sonar.service # copy the below green highlighted commands in the above file [Unit] Description=SonarQube service After=syslog.target network.target [Service] Type=forking ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop User=root Group=root Restart=always [Install] WantedBy=multi-user.target




Wednesday, May 25, 2022

No such property: docker for class: groovy.lang.Binding | Jenkins Pipeline Error Docker Build | Jenkins docker pipeline error

Jenkins Pipeline Error: 

groovy.lang.MissingPropertyException: No such property: docker for class: groovy.lang.Binding.

We most likely encountered the same issue, in order to fix it, install Docker Pipeline plugin in Jenkins:

Root Cause and Fix:

Jenkins need to have Docker Pipeline plug-in to perform Docker builds.

Jenkins > Manage Jenkins > Manage Plugins > Available tab

Search for Docker Pipeline install it, restart Jenkins and you are ready to go.


Friday, May 20, 2022

How to check whether my user data passing to EC2 instance is working | AWS EC2 bootstrap script log

The cloud-init output log file (/var/log/cloud-init-output.log) captures console output so it is easy to debug your scripts following a launch if the instance does not behave the way you intended.

Check the Logs in EC2 instance

Login to EC2 instance, and type the below command:

tail -f /var/log/cloud-init-output.log

This will give the output of bootstrap execution

Saturday, October 9, 2021

Certificate verification failed: The certificate is NOT trusted | Jenkins installation Error Fix | Jenkins Installation on Ubuntu 18.0.4 | Jenkins Installation on Ubuntu 20.0.4

If you try to install Jenkins on Ubuntu 18.0.4/20.0.4 instance, you may experience this problem.

Running sudo apt-get update on my AWS EC2 Ubuntu 18.04.01 LTS instance fails because Certificate verification failed: The certificate is NOT trusted.

Err:6 https://pkg.jenkins.io/debian-stable binary/ Release


Certificate verification failed: The certificate is NOT trusted. The certificate chain uses expired certificate.  Could not handshake: Error in the certificate verification. [IP: 199.232.66.133 443]

Fix for the above error

You need to install certificates to overcome this error:

sudo apt install ca-certificates

sudo apt-get update

Now try installing Jenkins

sudo apt install jenkins -y



Thursday, August 19, 2021

stderr: remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead | Fix for this issue | How to Create Personal Access Token in GitHub?

How to Create Personal Access Token in GitHub?

Fix for Support for password authentication was removed on August 13, 2021

How to Fix for the above error by creating Personal Access Token:GitHub removed password authentication support from August 13, 2021 instead it recommends to use either OAuth or Personal Access Token.

Create Personal Access Token in GitHub

Go to GitHub.com--> Settings

Go to Developer Settings 
Go to Personal Access tokens --> Generate new token
Enter name for the token, choose no expiration if you don't want your token to expire.


Select repo and click generate token

Now copy the token and use this as password.

Watch here on how to do this on YouTube Channel:

Thursday, July 15, 2021

Unable to locate credentials - Ansible on AWS | NoCredentialsError: Unable to locate credentials

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: NoCredentialsError: Unable to locate credentials

fatal: [localhost]: FAILED! => {"boto3_version": "1.17.112", "botocore_version": "1.20.112", "changed": false, "msg": "Error in describe_security_groups: Unable to locate credentials"}

When ever you get this error, make sure you have right credentials setup in your EC2 instance or you have attached right IAM role with policy.

Option 1 

Create an IAM role and attach AmazonEC2FullAccess policy. and then attach this role to EC2 instance.

Option 2

sudo vi ~/.boto

add below three lines in the above file, replace the ?? with access key and secret key values.

[Credentials]
aws_access_key_id = ??
aws_secret_access_key = ??


Sunday, November 29, 2020

How to fix Jenkins Error | Incorrect Java 11 version

You may have this issue when trying to install Jenkins with default JDK version(Java 11) in Ubuntu 18.0.4. We need to fix by installing JDK 8.

Remove Jenkins first.

sudo apt-get remove jenkins -y
 

Install Java 8 version

sudo apt-get install openjdk-8-jdk -y


Now choose which version to select from both Java 11 and Java 8 
sudo update-alternatives --config java
type 2 to choose Java 8 version.

Check Java version after setting:

Install Jenkins

sudo apt-get install jenkins -y
Now try to access Jenkins in the browser.

Code error 403 when trying to access Kubernetes cluster | Jenkins Kubernetes Deployment

When ever you are doing deployment from Jenkins to EKS cluster, you may get this error:

Api call failed with code 403, detailed message: {
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {
    
  },

"status": "Failure",
  "message": "namespaces is forbidden: User \"system:anonymous\" cannot list namespaces at the cluster scope",
  "reason": "Forbidden",
  "details": {
    "kind": "namespaces"
  },
  "code": 403 
Work around or the fix: 

You get this error because you're getting blocked by RBAC policies. Basically, RBAC policies set to restrict the resources you use and limits a few of your action. 

There are two possibilities, either you haven't created an RBAC or it's somehow restricting the cluster access.

By default, your clusterrolebinding has system:anonymous set which blocks the cluster access.

Execute the following command, it will set a clusterrole as cluster-admin which will give you the required access.

kubectl create clusterrolebinding cluster-system-anonymous --clusterrole=cluster-admin --user=system:anonymous

 

Saturday, August 1, 2020

How to Reset Jenkins Admin password | Jenkins admin password unlock | Forgotten Jenkins Admin Password | How to Recover Jenkins admin password

How to Reset the Jenkins administrator password?

Let's say you have forgotten Jenkins admin password. How to reset or retrieve the admin password? Here below are the steps for resetting Jenkins admin password:

1. Edit the Jenkins config.xml under /var/lib/jenkins to disable securityFlag by executing below command:

sudo vi /var/lib/jenkins/config.xml


you need to disable security to Jenkins by below change
2. Find this <useSecurity>true</useSecurity> and change it to <useSecurity>false</useSecurity>
3. Restart Jenkins by below command:
sudo service jenkins restart
4. Access Jenkins now, click on Manage Jenkins, click on configure Global security 

5. click on Enable security 

6. Click on Jenkins Own user database option.



7. click on apply and save
8. Now click on Manage users, click on admin, click on configure






  9. Enter new password and apply/save

After changing the password, you will be able to log into your Jenkins controller again using the same username and the new password that you have just set.

Enable security

  1. Log in as your admin account.

  2. On the dashboard, select Manage Jenkins in the navigation pane on the left side of the page.

  3. On the Manage Jenkins page, under the Security section, select Configure Global Security.

  4. Set the Authorization to Logged-in users can do anything. Uncheck the option Allow anonymous read access. Select Save.

Tuesday, February 11, 2020

Unable to upload WAR file into Nexus, Not Authorized error

 Unable to upload WAR file into Nexus,  Not Authorized error 


Root cause and Fix:
Make sure you are using right credentials for Nexus which is admin/admin123, and also you need to select from drop down. And also make sure you select Nexus 3 if you are using Nexus3.

Not authorized. Please check the properties sonar.login and sonar.password


Not authorized. Please check the properties sonar.login and sonar.password




root cause and fix:

SonarQube token was not setup correctly. You need to login in SonarQube as an administrator and create token. Copy the token in Jenkins --> Manage Jenkins--> sonarqube section and re-run the build.

Master DevSecOps and Multi Cloud Computing Course by Coach AK | DevSecOps and Cloud Computing Online Classes | Sep 2025 Schedule

  Master DevSecOps and cloud Computing Bootcamp Schedule for Sep 2025 Are you ready to  supercharge your career  in  DevSecOps ? Whether you...