- A simple go app which just says hello
-
A multistage Dockerfile - first part builds source code into binary
-
Second part takes binary from first part and creates an image
docker build -t app .
docker run -it --rm -p 8080:8080 app
$ docker tag app vishalbiyani/app
$ docker push vishalbiyani/app
Every Kubernetes object is defined by a standard format
- The
apiVersion
andkind
define the kind of object. Metadata
has all the metadata about that object such as name, labels, annotations etc.Spec
- is the core definition of the object itself and varies from object to object
apiVersion: v1
kind: <ObjectKind>
metadata:
name: <Name>
labels:
<key>: <value>
spec:
name: <Name>
So let's define a simple pod spec
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: myapp-container
image: vishalbiyani/app
Similarly define a service spec:
apiVersion: v1
kind: Service
metadata:
name: simpleapp
labels:
svc: myapp
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 8080
selector:
app: myapp
$ kubectl apply -f pod.yaml
$ kubectl apply -f service.yaml
$ kubectl get service