Skip to content

Instantly share code, notes, and snippets.

@jendiamond
Last active March 7, 2019 19:58
Show Gist options
  • Select an option

  • Save jendiamond/a5d376f60c56cc550c13be2736be4bb8 to your computer and use it in GitHub Desktop.

Select an option

Save jendiamond/a5d376f60c56cc550c13be2736be4bb8 to your computer and use it in GitHub Desktop.

Kubernetes

Pods

3 service types

  • Node Port (for toy apps)
  • Load Balancer (binds to a service)
  • Ingress (nginx proxying)(scalable way)

Kube Security Basics

  • Secrets
    • stored in cluster
    • exposed to containers via ENV or filesystem
  • Service Accounts
    • by defauklt applications
  • Role Assignment + +

Tutorial

Installation

🦖 brew install kubernetes-cli
🦖 brew link --overwrite --dry-run kubernetes-cli
🦖 kubectl
🦖 kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"} 🦖brew cask install minikube 🦖minikube start 🦖kubectl get pods 🦖kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.10 --port=8080`


Tutorial

🦖 kubectlget pods
🦖 git clone https://gitlab.com/ibm/kube101
🦖 cd kube101/
🦖 cd status_page/
🦖 docker build -t jendiamond/1 ./


watson-twitch-tone-analysis/deploy/

Note: three dashes creates a multiple yaml data structure

apiVersion: apps/v1
kind: Deployment
metadata:
  name: watson-twitch-tone-analysis
  namespace: clean
  labels:
    app: watson-twitch-tone-analysis
spec:
  replicas: 1
  selector:
    matchLabels:
       app: watson-twitch-tone-analysis
  template:
    metadata:
      labels:
        app: watson-twitch-tone-analysis
    spec:
      containers:
      - name: watson-twitch-tone-analysis
        image: nibalizer/watson-twitch-tone-analysis:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 3000
        volumeMounts:
        - name: configjson
          mountPath: "/usr/src/app/secrets"
          readOnly: true
      volumes:
      - name: configjson
        secret:
          secretName: watson-twitch-tone-analysis-secret
---
kind: Service
apiVersion: v1
metadata:
  name: watson-twitch-tone-analysis
  namespace: clean
spec:
  selector:
    app: watson-twitch-tone-analysis
  ports:
  - protocol: TCP
    port: 3000
    name: watson-twitch-tone-analysis
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: main-ingress
  namespace: clean
spec:
  rules:
  - host: apps.nibalizer.net
    http:
      paths:
      - path: /watson-twitch-tone-analysis
        backend:
          serviceName: watson-twitch-tone-analysis
          servicePort: 3000
      - path: /socket.io/
        backend:
          serviceName: watson-twitch-tone-analysis
          servicePort: 3000   

HA Proxy is free, open source software that provides a high availability load balancer and proxy server for TCP and HTTP-based applications that spreads requests across multiple servers.[1] It is written in C[2] and has a reputation for being fast and efficient (in terms of processor and memory usage).[3]

F5 is a global company that specializes in application services and application delivery networking (ADN). F5 technologies focus on the delivery, security, performance, and availability of web applications, as well as the availability of servers, cloud resources, data storage devices, and other networking components. F5 is headquartered in Seattle, Washington, with additional development, manufacturing, and sales/marketing offices worldwide.


Kubes DNS

you must have a Service for every deployment

Ingress Traditionally, you would create a LoadBalancer service for each public system you want to expose. This can get rather expensive. Ingress gives you a way to route requests to services based on the request host or path, centralizing a number of services into a single entrypoint.

Kubernetes ingress is a collection of routing rules that govern how external users access services running in a Kubernetes cluster. However, in real-world Kubernetes deployments, there are frequently additional considerations beyond routing for managing ingress. We’ll discuss these requirements in more detail below.


CLI

$ k get pod
$ k logs watson-twitch-tone-analysis
$ k get ing
$ k describe ing/main-ingress | less
$ k get secret -o yaml watson-twitch-tone-analysis-secret | less
$ k get svc (services)
$ k get deploy

replica sets ---> replica controllers

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