Skip to content

Instantly share code, notes, and snippets.

@vandorjw
Last active November 30, 2018 14:38
Show Gist options
  • Save vandorjw/e9f9dfee1b6fb8c3fe0c5e85967482a3 to your computer and use it in GitHub Desktop.
Save vandorjw/e9f9dfee1b6fb8c3fe0c5e85967482a3 to your computer and use it in GitHub Desktop.
Simple local Jenkins
$ 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.
@vandorjw
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment