Skip to content

Instantly share code, notes, and snippets.

View percybolmer's full-sized avatar

ProgrammingPercy percybolmer

View GitHub Profile
@percybolmer
percybolmer / Kubernetes-101-mysql.go
Created August 9, 2022 05:46
Kubernetes connecting to mysql
package main
import (
"context"
"database/sql"
"errors"
"fmt"
"log"
"os"
"time"
@percybolmer
percybolmer / Kubernetes-101-01_database.yml
Last active August 6, 2022 04:43
K8 object for database + service.
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
namespace: hellogopher # Use the hellogopher namespace
spec:
selector:
matchLabels:
app: mysql
strategy:
apiVersion: v1
kind: Namespace
metadata:
name: hellogopher
@percybolmer
percybolmer / Kubernetes-101-database.yaml
Created August 5, 2022 07:06
Kubernetes for mysql deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
selector:
matchLabels:
app: mysql
strategy:
type: Recreate
package main
import (
"fmt"
"log"
"net/http"
"time"
)
func main() {
@percybolmer
percybolmer / Kubernetes-101-livenessProbe.yml
Created August 2, 2022 18:55
kubernetes liveness probe
apiVersion: apps/v1 #Which version of the Kubernetes API you're using to create this object
kind: Deployment # What kind of object you want to create [deployment, service etc]
metadata: # Data that helps uniquely identify the object, including a name string, UID, and optional namespace
name: hellogopher
spec: # What state you desire for the object
selector: # Define what selectors the Deployment uses to find the PODS that are related to it
matchLabels: # matchLabels is a map of {key,value} pairs.
app: hellogopher
replicas: 1 # Tells the deployment to run 1 pod
template: # When creating new pods, this template will be used
@percybolmer
percybolmer / Kubernetes-101-readynessProbe.yml
Created August 2, 2022 18:38
readyness probe in kubectl
apiVersion: apps/v1 #Which version of the Kubernetes API you're using to create this object
kind: Deployment # What kind of object you want to create [deployment, service etc]
metadata: # Data that helps uniquely identify the object, including a name string, UID, and optional namespace
name: hellogopher
spec: # What state you desire for the object
selector: # Define what selectors the Deployment uses to find the PODS that are related to it
matchLabels: # matchLabels is a map of {key,value} pairs.
app: hellogopher
replicas: 1 # Tells the deployment to run 1 pod
template: # When creating new pods, this template will be used
@percybolmer
percybolmer / Kubernetes-101-specInYml.yaml
Created August 2, 2022 07:08
Kubernetes added Spec
apiVersion: apps/v1 #Which version of the Kubernetes API you're using to create this object
kind: Deployment # What kind of object you want to create [deployment, service etc]
metadata: # Data that helps uniquely identify the object, including a name string, UID, and optional namespace
name: hellogopher
spec: # What state you desire for the object
selector: # Define what selectors the Deployment uses to find the PODS that are related to it
matchLabels: # matchLabels is a map of {key,value} pairs.
app: hellogopher
replicas: 1 # Tells the deployment to run 1 pod
template: # When creating new pods, this template will be used
@percybolmer
percybolmer / Kubernetes-101-defaultsInYaml.yaml
Created August 2, 2022 06:58
kubernetes defaults fields
apiVersion: apps/v1 #Which version of the Kubernetes API you're using to create this object
kind: Deployment # What kind of object you want to create [deployment, service etc]
metadata: # Data that helps uniquely identify the object, including a name string, UID, and optional namespace
name: hellogopher
FROM golang:alpine as builder
WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o hellogopher -ldflags="-w -s"
ENTRYPOINT [ "./hellogopher" ]