Skip to content

Instantly share code, notes, and snippets.

View kainlite's full-sized avatar
:shipit:

Gabriel Garrido kainlite

:shipit:
View GitHub Profile
@kainlite
kainlite / kubernetes.tf
Created May 5, 2019 22:11
terraform kubernetes
# Create the cluster
resource "digitalocean_kubernetes_cluster" "dev-k8s" {
name = "dev-k8s"
region = "nyc1"
version = "1.14.1-do.2"
node_pool {
name = "dev-k8s-nodes"
size = "s-1vcpu-2gb"
node_count = 1
@kainlite
kainlite / lb.tf
Created May 5, 2019 22:12
terraform load balancer
# Create a load balancer associated with our cluster
resource "digitalocean_loadbalancer" "public" {
name = "loadbalancer-1"
region = "nyc1"
forwarding_rule {
entry_port = 80
entry_protocol = "http"
target_port = 30000
@kainlite
kainlite / output.tf
Created May 5, 2019 22:13
terraform output
# Export the kubectl configuration file
resource "local_file" "kubernetes_config" {
content = "${digitalocean_kubernetes_cluster.dev-k8s.kube_config.0.raw_config}"
filename = "kubeconfig.yaml"
}
# Print the load balancer ip
output "digitalocean_loadbalancer" {
value = "${digitalocean_loadbalancer.public.ip}"
description = "The public IP address of the load balancer."
@kainlite
kainlite / .travis.yml
Created May 5, 2019 22:15
travis-ci kubernetes
language: go
services:
- docker
before_install:
- docker build --no-cache -t ${TRAVIS_REPO_SLUG}:${TRAVIS_COMMIT} .
- docker run ${TRAVIS_REPO_SLUG}:${TRAVIS_COMMIT} /go/src/github.com/kainlite/whatismyip-go/whatismyip-go.test
- docker run -d -p 127.0.0.1:8000:8000 ${TRAVIS_REPO_SLUG}:${TRAVIS_COMMIT}
@kainlite
kainlite / kubeconf.yml
Created May 5, 2019 22:23
Example config
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURKekNDQWcrZ0F3SUJBZ0lDQm5Vd0RRWUpLb1pJaHZjTkFRRUxCUUF3TXpFVk1CTUdBMVVFQ2hNTVJHbG4KYVhSaGJFOWpaV0Z1TVJvd0dBWURWUVFERXhGck9ITmhZWE
@kainlite
kainlite / manifest.yml.template
Last active May 5, 2019 22:34
kubernetes example deployment
---
apiVersion: v1
kind: Service
metadata:
name: whatismyip-go-service
spec:
type: NodePort
ports:
- port: 8000
targetPort: 8000
$ curl -v 142.93.207.200:30000
* Trying 142.93.207.200...
* TCP_NODELAY set
* Connected to 142.93.207.200 (142.93.207.200) port 30000 (#0)
> GET /
$ curl -v 159.203.156.153
* Trying 159.203.156.153...
* TCP_NODELAY set
* Connected to 159.203.156.153 (159.203.156.153) port 80 (#0)
> GET / HTTP/1.1
$ kubectl get pods --kubeconfig=./kubeconfig.yaml
NAME READY STATUS RESTARTS AGE
whatismyip-go-deployment-5ff9894d8c-f48nx 1/1 Running 0 9s
# Initialize terraform
$ terraform init
Initializing provider plugins...
- Checking for available provider plugins on https://releases.hashicorp.com...