Skip to content

Instantly share code, notes, and snippets.

@nellshamrell
Last active May 3, 2019 22:44
Show Gist options
  • Save nellshamrell/9913f6a1350cadf6fff7fff34be91c63 to your computer and use it in GitHub Desktop.
Save nellshamrell/9913f6a1350cadf6fff7fff34be91c63 to your computer and use it in GitHub Desktop.
Habitat Kubernetes notes

Basics:

git clone https://github.com/habitat-sh/sample-node-app
cd sample-node-app
npm install
vim habitat/plan.sh # Replace your_origin with your origin
hab studio enter
build

Exporting to Docker

hab pkg export docker ./results/nellshamrell-sample-node-app-1.1.0-20190503213831-x86_64-linux.hart --push-image -U nellshamrell -P ...
exit
docker run -it -p 8000:8000 nellshamrell/sample-node-app

Navigate to http://0.0.0.0:8000 in browser

Exporting to Kubernetes

hab pkg export kubernetes ./results/nellshamrell-sample-node-app-1.1.0-20190503213831-x86_64-linux.hart --push-image -U nellshamrell -P ... -o sample_node_app.yaml
kubectl create -f ./sample_node_app.yaml
kubectl expose statefulset
@nellshamrell
Copy link
Author

Working Kubernetes manifest

15:43:11-nellshamrell~/Projects/sample-node-app (master)$ cat sample-node-app.yaml
apiVersion: habitat.sh/v1beta1
kind: Habitat
customVersion: v1beta2
metadata:
  ## Name of the Kubernetes resource.
  name: sample-node-app-1-1-0-20190503213831
spec:
  v1beta2:
    ## Name of the Habitat service package exported as a Docker image.
    image: nellshamrell/sample-node-app:1.1.0-20190503213831
    ## Number of desired instances.
    count: 1
    ## An object containing parameters that affects how the Habitat service
    ## is executed.
    service:
      ## Name of the Habitat service.
      name: sample-node-app
      ## Habitat topology of the service.
      topology: standalone
---
apiVersion: v1
kind: Service
metadata:
  name: app-0
spec:
  type: LoadBalancer
  selector:
    habitat-name: sample-node-app-1-1-0-20190503213831
  ports:
  - protocol: TCP
    port: 8000
    targetPort: 8000

Can access the running application at http://service_ip:8000

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