Reputation: 23
I've installed Jenkins on my Ubuntu machine running on compute engine in Google Cloud.
To do so I have run these commands:
sudo apt-get update
sudo apt-get install apache2 libapache2-mod-php5 php5-mcrypt php5-mysql git openjdk-7-jre openjdk-7-jdk -y
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
Jenkins seems to be installing fine but when i go to the public IP address on port 8080 there nothing there. I read that it may be so that Apache is using port 8080 so I edited /etc/default/jenkins
and changed the port to 8081. Still I don't see jenkins on that port.
I've also restarted the service but no change there. If I do:
sudo netstat -plntu
I see:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 422/sshd
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9745/apache2
tcp6 0 0 :::22 :::* LISTEN 422/sshd
tcp6 0 0 :::8081 :::* LISTEN 17917/java
udp 0 0 0.0.0.0:53763 0.0.0.0:* 294/dhclient
udp 0 0 0.0.0.0:68 0.0.0.0:* 294/dhclient
udp 0 0 10.132.0.2:123 0.0.0.0:* 372/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 372/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 372/ntpd
udp6 0 0 :::9732 :::* 294/dhclient
udp6 0 0 :::33848 :::* 17917/java
udp6 0 0 ::1:123 :::* 372/ntpd
udp6 0 0 :::123 :::* 372/ntpd
udp6 0 0 :::5353 :::* 17917/java
If I check the status of the services it seems to be running:
[ + ] acpid
[ + ] apache2
[ - ] bootlogs
[ - ] bootmisc.sh
[ - ] checkfs.sh
[ - ] checkroot-bootclean.sh
[ - ] checkroot.sh
[ + ] cron
[ + ] dbus
[ - ] generate-ssh-hostkeys
[ - ] hostname.sh
[ - ] hwclock.sh
[ + ] jenkins
[ - ] killprocs
[ + ] kmod
[ - ] motd
[ - ] mountall-bootclean.sh
[ - ] mountall.sh
[ - ] mountdevsubfs.sh
[ - ] mountkernfs.sh
[ - ] mountnfs-bootclean.sh
[ - ] mountnfs.sh
[ + ] networking
[ + ] ntp
[ + ] procps
[ + ] rc.local
[ - ] rmnologin
[ - ] rsync
[ + ] rsyslog
[ - ] screen-cleanup
[ - ] sendsigs
[ + ] ssh
[ - ] sudo
[ + ] udev
[ + ] udev-finish
[ - ] umountfs
[ - ] umountnfs.sh
[ - ] umountroot
[ - ] unattended-upgrades
[ + ] urandom
[ - ] uuidd
[ - ] x11-common
Can someone tell me what I am doing wrong here?
Upvotes: 0
Views: 2350
Reputation: 21
run this after putting project name gcloud compute --project=<project_name> firewall-rules create firewall-8080 --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules=tcp:8080 --source-ranges=0.0.0.0/0
Upvotes: 0
Reputation: 49583
As far as the VM is concerned, it looks like Jenkins
is indeed running (based on the output from netstat
and the list of running services):
tcp6 0 0 :::8081 :::* LISTEN 17917/java
Jenkins is a java application, and hence the process might only show up as java
.
It look like you're trying to access the service through the instance's public IP and port. The Google Compute Engine (GCE) firewall might be blocking this, since by default all incoming ports from external IPs in GCE VMs are blocked.
If your goal is to access this port on this machine from any public IP, you can follow these steps to grant access:
# Create a new firewall rule that allows INGRESS tcp:8081 with VMs containing tag 'allow-tcp-8081'
gcloud compute firewall-rules create rule-allow-tcp-8081 --source-ranges 0.0.0.0/0 --target-tags allow-tcp-8081 --allow tcp:8081
# Add the 'allow-tcp-8081' tag to a VM named VM_NAME
gcloud compute instances add-tags VM_NAME --tags allow-tcp-8081
# If you want to list all the GCE firewall rules
gcloud compute firewall-rules list
Menu -> Networking -> Firewall Rules
Create Firewall Rule
Choose the following settings for the firewall rule:
Name
for the rule - rule-allow-tcp-8081
or any other name you prefer for this firewall rule.Direction
is ingress
Action on match
is Allow
Targets
is Specified target tags
Target tags
is allow-tcp-8081
Source IP ranges
is 0.0.0.0/0
(or if you have a set of IP ranges you know will be the only ones accessing this, use them instead for stronger restriction)Protocols and ports
is tcp:8081
Create
button to create this firewall rule.Once you've created the above firewall rule you will need to add the tag allow-tcp-8081
to all the instances where this rule needs to be applied. In your case:
VM Instances
pageVM instance details
page, select the Edit
link on the very top.Network Tags
box, enter allow-tcp-8081
to apply the tag to this instance.Save
to save the changes.Now give it a few seconds to a few minutes for the changes to take effect and you will be able to access the jenkins web URL.
You can also go through the documentation for Firewall rules to get a better understanding of how they work and how to configure them.
NOTE: By using a source range of 0.0.0.0/0
, you're opening up this port to the entire internet, so clients anywhere in the world will be able to connect to this port. Be aware of the security implications of doing this.
Upvotes: 5