Skip to content

pablosilvab/demo-golang-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo Docker & Golang

Go Report Card Build Actions Status

This is a simple API for testing different tools.

golang docker kubernetes elastic

Run project locally

  1. Clone project
go get github.com/pablosilvab/golang-docker
  1. Go to folder
cd ~/go/src/github.com/pablosilvab/golang-docker
  1. Download dependencies
go mod download
  1. Run project locally
make go-run
  1. Compile the code and generate an executable
make go-build
  1. Run the executable
make go-shell

Run with Docker

  • Build new image
make docker-build
  • Generate tag
make docker-tag
  • Run container
make docker-run

Helm

Requirements

  • Helm
  • Tiller

Install package in Kubernetes:

make helm-install

Remove release in Kubernetes:

make helm-uninstall

List all releases:

helm ls --all

Issues

Deploy

  • Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

Review .gitlab-ci.yml file.

Helm install

  • User "system:serviceaccount:default:default" cannot get at the cluster

Grant permissions with ClusterRoleBinding.

How create charts?

helm create charts

Notes

Run elasticsearch in K8s.

To run elasticsearch in K8s for this exercise I use helm

  1. Add repository elastic
helm repo add bitnami https://charts.bitnami.com/bitnami
  • Install helm chart
helm install elastic bitnami/elasticsearch
  • Uninstall chart
helm delete --purge elastic
  • Expose the service
kubectl port-forward --namespace default svc/elastic-elasticsearch 9200:9200