Skip to content

Instantly share code, notes, and snippets.

View percybolmer's full-sized avatar

ProgrammingPercy percybolmer

View GitHub Profile
@percybolmer
percybolmer / Kubernetes-101-02_hellogopher_v4.yaml
Created August 13, 2022 07:01
Kubernetes deployment with resource limitation
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
namespace: 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
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
namespace: 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
---
apiVersion: v1
kind: Secret
metadata:
name: database-secrets
namespace: hellogopher
type: Opaque
data:
DATABASE_PASSWORD: cGFzc3dvcmQ=
---
apiVersion: v1
kind: ConfigMap
metadata:
name: database-configs
namespace: hellogopher
data:
DATABASE_USERNAME: root
DATABASE_NAME: test
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
namespace: 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
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
namespace: 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
DATABASE_USERNAME=root
DATABASE_NAME=test
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
namespace: 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
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
namespace: 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
@percybolmer
percybolmer / Kubernetes-101-main_v2.go
Created August 9, 2022 05:48
Kuberenetes main with connecting to db
package main
import (
"fmt"
"log"
"net/http"
"os"
"time"
)