Last active
November 30, 2018 14:38
-
-
Save vandorjw/e9f9dfee1b6fb8c3fe0c5e85967482a3 to your computer and use it in GitHub Desktop.
Simple local Jenkins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo snap install microk8s | |
$ microk8s.enable dns dashboard ingress | |
$ nap alias microk8s.kubectl kubectl | |
$ kubectl config view --raw > $HOME/.kube/config | |
Download terraform: https://www.terraform.io/downloads.html | |
$ mkdir -p workspace/jenkins | |
$touch example.tf and insert ... | |
resource "kubernetes_pod" "jenkins" { | |
metadata { | |
name = "jenkins" | |
labels { | |
App = "jenkins" | |
} | |
} | |
spec { | |
container { | |
image = "jenkins/jenkins:lts" | |
name = "jenkins" | |
port { | |
container_port = 8080 | |
} | |
} | |
} | |
} | |
resource "kubernetes_service" "jenkins" { | |
metadata { | |
name = "jenkins" | |
} | |
spec { | |
selector { | |
App = "${kubernetes_pod.jenkins.metadata.0.labels.App}" | |
} | |
port { | |
port = 80 | |
target_port = 8080 | |
} | |
type = "ClusterIP" | |
} | |
} | |
$ terraform init | |
$ terraform apply | |
$ kubectl get services | |
Note the cluster-ip from jenkins, navigate to it in your browser.. | |
$ kubectl exec -it jenkins -- /bin/bash | |
# cat /var/jenkins_home/secrets/initialAdminPassword | |
copy the password. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From: https://microk8s.io/docs/
My pods can’t reach the internet (but my MicroK8s host machine can).
Make sure packets to/from the pod network interface can be forwarded to/from the default interface on the host:
sudo iptables -P FORWARD ACCEPT
or, if using ufw:
sudo ufw default allow routed