Skip to content

Commit

Permalink
Adding service.yaml.
Browse files Browse the repository at this point in the history
  • Loading branch information
algogrit committed Aug 9, 2019
1 parent ccf6efc commit 89e2885
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 12 deletions.
8 changes: 3 additions & 5 deletions code-samples/11-kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ Or clone the repo and run `./install.sh`
```bash
minikube start --vm-driver=kvm2

# ./source.sh
export NO_PROXY=$no_proxy,$(minikube ip)

kubectl version
. source.sh
```

### Multi node cluster using Kind
Expand All @@ -32,7 +29,8 @@ Or clone the repo and run `./install.sh`
Follow steps in [setup-proxy.md](https://github.com/AgarwalConsulting/java-training/blob/master/code-samples/11-kubernetes/setup-proxy.md)

```bash
kind build node-image
./build-image.sh

kind create cluster --config kind-config.yml
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ git clone https://github.com/kubernetes/kubernetes.git ~/.go/src/k8s.io/kubernet
echo "Creating kind cluster..."
# kind delete cluster
kind build node-image
kind create cluster --config kind-config.yml
18 changes: 18 additions & 0 deletions code-samples/11-kubernetes/config/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: extensions/v1beta1
kind: Service
metadata:
name: gs-rest-service
labels:
name: gs-rest-service
spec:
# if your cluster supports it, uncomment the following to automatically create
# an external load-balanced IP for the frontend service.
# type: LoadBalancer
type: NodePort
ports:
# the port that this service should serve on
- port: 8080
nodePort: 30080
selector:
name: gs-rest
2 changes: 1 addition & 1 deletion code-samples/11-kubernetes/docker-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"httpProxy": "http://10.19.16.165:8080",
"httpsProxy": "http://10.19.16.165:8080",
"noProxy": "localhost,127.0.0.0/8,::1"
"noProxy": "localhost,127.0.0.0/8,::1,172.17.0.0/16"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bash

# Start a Kubernetes locally
minikube start

# Start a Kubernetes locally using either minikube or Kind
kubectl cluster-info

# Create a deployment
Expand All @@ -13,15 +11,23 @@ kubectl proxy &

# Check if the server in the pod is accessible
curl http://localhost:8001/version

export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
echo Name of the Pod: $POD_NAME
curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy/

# Apply a nginx deployment
kubectl apply -f https://k8s.io/examples/controllers/nginx-deployment.yaml

# Starting gs-rest-service as a deployment
kubectl create deployment gs-rest --image=gauravagarwalr/spring-greeting:latest
kubectl apply -f config/deployment.yaml
kubectl apply -f config/service.yaml

# Status
kubectl get nodes
kubectl get namespaces
kubectl get pods -o wide
kubectl get deployments
kubectl get rc
kubectl get services
2 changes: 1 addition & 1 deletion code-samples/11-kubernetes/setup-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"httpProxy": "http://10.19.16.165:8080",
"httpsProxy": "http://10.19.16.165:8080",
"noProxy": "localhost,127.0.0.0/8,::1"
"noProxy": "localhost,127.0.0.0/8,::1,172.17.0.0/16"
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion code-samples/11-kubernetes/source.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#!/usr/bin/env bash

export NO_PROXY=$no_proxy,$(minikube ip)
export NO_PROXY=$no_proxy,172.17.0.0/16
export HTTP_PROXY="http://10.19.16.165:8080"
export HTTPS_PROXY="http://10.19.16.165:8080"

export no_proxy=$no_proxy,172.17.0.0/16
export http_proxy="http://10.19.16.165:8080"
export https_proxy="http://10.19.16.165:8080"

export NO_PROXY=$NO_PROXY,$(minikube ip)
export no_proxy=$no_proxy,$(minikube ip)

0 comments on commit 89e2885

Please sign in to comment.