---
# System prepended metadata

title: kubernetes practice for "LoadBalancer"
tags: [practice, kubernetes]

---

kubernetes practice for "LoadBalancer"
======
###### tags: `kubernetes` `practice`

## command
```shell=
gcloud container clusters create k8s-practice --num-nodes 3 --machine-type f1-micro

gcloud container clusters list
kubectl config get-contexts
```
```shell=
git clone https://github.com/jatins/express-hello-world.git
cd express-hello-word
docker build -t gcr.io/{PROJECT_ID}/hello-world-image:v1 .
gcloud docker -- push gcr.io/{PROJECT_ID}/hello-world-image:v1
```

```shell=
kubectl create ns hello
kubectl create -f deployment.yml -n hello --save-config
kubectl expose deployment hello-world-deployment -n hello --type="LoadBalancer"
```
```shell=
kubectl get service -n hello
kubectl get deploy -n hello
kubectl get pods -n hello
kubectl apply -f deployment.yml -n hello
```

```shell=
kubectl delete ns hello
kubectl delete -f deployment.yml
kubectl delete service/hello-world-deployment
gcloud container clusters delete k8s-practice
```

## deploymemt.yml
```yaml=
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: hello-world-deployment
spec:
  replicas: 2
  template:
    metadata:
      labels: # labels to select/identify the deployment
        app: hello-world
    spec:     # pod spec
      containers:
      - name: hello-world
        image: gcr.io/bruce-211006/hello-world-image:v3 # image we pushed
        ports:
        - containerPort: 3000
```