All Projects → amsokol → openshift-golang-template

amsokol / openshift-golang-template

Licence: Apache-2.0 license
Template for running Go programs on OpenShift v3

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
Makefile
30231 projects

Projects that are alternatives of or similar to openshift-golang-template

go-api-basic
A Go RESTful API template
Stars: ✭ 313 (+1741.18%)
Mutual labels:  golang-template
s2i-ruby-container
Ruby container images based on Red Hat Software Collections and intended for OpenShift and general usage, that provide a platform for building and running Ruby applications. Users can choose between Red Hat Enterprise Linux, Fedora, and CentOS based images.
Stars: ✭ 55 (+223.53%)
Mutual labels:  openshift
istio-workspace
Safely develop and test on any Kubernetes cluster without affecting others.
Stars: ✭ 55 (+223.53%)
Mutual labels:  openshift
anthill
A Kubernetes/OpenShift operator to manage Gluster clusters
Stars: ✭ 35 (+105.88%)
Mutual labels:  openshift
ocp4upc
OCP4 Upgrade Paths Checker
Stars: ✭ 30 (+76.47%)
Mutual labels:  openshift
dockerevil
My security researches involving Docker and Openshift
Stars: ✭ 28 (+64.71%)
Mutual labels:  openshift
openshift-cartridge-mysql
Custom cartridge for OpenShift providing MySQL 5.7.17
Stars: ✭ 13 (-23.53%)
Mutual labels:  openshift
web
Hugo content for the openshift.tips blog
Stars: ✭ 48 (+182.35%)
Mutual labels:  openshift
Chowkidar
A kubernetes controller that watches/observes events & then takes configured actions – [✩Star] if you're using it!
Stars: ✭ 55 (+223.53%)
Mutual labels:  openshift
openshift-slack-notifications
OpenShift slack notifications
Stars: ✭ 14 (-17.65%)
Mutual labels:  openshift
ChRIS ultron backEnd
Backend for ChRIS
Stars: ✭ 28 (+64.71%)
Mutual labels:  openshift
camunda-cloud-helm
Camunda Platform 8 Self-Managed Helm charts
Stars: ✭ 41 (+141.18%)
Mutual labels:  openshift
kubernetes-kafka
Managing kafka clusters in Kubernetes and OpenShift
Stars: ✭ 18 (+5.88%)
Mutual labels:  openshift
jetlag
Automation to deploy Bare-metal OpenShift leveraging the Assisted-Installer
Stars: ✭ 18 (+5.88%)
Mutual labels:  openshift
kuberig
Deploy to Kubernetes/OpenShift by leveraging your developer skills - no yaml required!
Stars: ✭ 31 (+82.35%)
Mutual labels:  openshift
kubernetes.core
The collection includes a variety of Ansible content to help automate the management of applications in Kubernetes and OpenShift clusters, as well as the provisioning and maintenance of clusters themselves.
Stars: ✭ 159 (+835.29%)
Mutual labels:  openshift
apb-examples
A repository of example ansible-playbook bundles. THIS REPO IS DEPRECATED. Please look at https://github.com/ansibleplaybookbundle/ For updated examples.
Stars: ✭ 15 (-11.76%)
Mutual labels:  openshift
shepherd
A Drupal-based controller to the Shepherd site management platform.
Stars: ✭ 16 (-5.88%)
Mutual labels:  openshift
ose-pivproxy
A containerized PIV/CAC/x509 proxy for OSE
Stars: ✭ 19 (+11.76%)
Mutual labels:  openshift
django-probes
Django app to run database liveness probe in a Kubernetes project
Stars: ✭ 32 (+88.24%)
Mutual labels:  openshift

Template for running Go programs on OpenShift v3 (version 1.4 and higher)

It supports:

Sample data to try golang template

Data Value
Go Go v1.9.2
OpenShift OpenShift Origin v1.5
Git repository https://github.com/amsokol/openshift-golang-template.git
Context directory /example-golang-dep
Folder with main.go to build and run /example-golang-dep/cmd/server

How to

  1. Login with Developer account to OpenShift:
# oc login --insecure-skip-tls-verify -u <username> https://openshift.example.com:8443
  1. Create new project:
# oc new-project project1
  1. Select project1 project:
# oc project project1
  1. Create ImageStream:
# oc create -f ./openshift-golang-template.yaml
  1. Login to OpenShift console using browser (e.g. https://openshift.example.com:8443) with Developer account

  2. Open project1 project

  3. Click Add to Project and select Go

  4. Select 1.9.2 - latest from drop down list and click Select

  5. Set Name to golang1

  6. Set Git Repository URL to https://github.com/amsokol/openshift-golang-template.git or click Try It

  7. Click advanced options to add additional configuration parameters

  8. Set Context Dir to /example-golang-dep (sample project with dep manager support)

  9. Add the following environment variables to Build Configuration section:

  • GOPROJECT_ROOT=github.com/amsokol/openshift-golang-template/example-golang-dep
  • GOPROJECT_CMD=cmd/server
GOPROJECT_ROOT tells builder the root package of go project
GOPROJECT_CMD tells builder the where "main()" function of "main" package to build and run is located (relative to GOPROJECT_ROOT).
Note: ignore GOPROJECT_CMD if "main()" function of "main" package is located in GOPROJECT_ROOT folder.

In example above "main()" function of "main" package is located in `github.com/amsokol/openshift-golang-template/example-golang-dep/cmd/server`.
GOPROJECT_ROOT is set to `github.com/amsokol/openshift-golang-template/example-golang-dep`.
So GOPROJECT_CMD is set to `cmd/server`
  1. [Optional] You can easy provide go build arguments. Just add GO_BUILD_ARGS environment variable to Build Configuration section. For example the following value tells go build to print the commands are run and packages are compiled:
GO_BUILD_ARGS=-x -v

Note: please DO NOT override output file name ("-o" argument)!
  1. [Optional] You can easy provide command line arguments to your binary. Just add GOPROJECT_CMD_ARGS environment variable to Deployment Configuration section. For example the following value provides --silent and --force arguments the binary:
GOPROJECT_CMD_ARGS=--silent --force
  1. [Optional] You can easy provide configuration files to your binary that are copied by the build script to GOPATH\bin (where your binary file is located). Just add GOPROJECT_CMD_CONFIG, GOPROJECT_CMD_CONFIG1, GOPROJECT_CMD_CONFIG2, GOPROJECT_CMD_CONFIG3, etc. environment variables to Build Configuration section. If your configuration files are located in the same project source control repository GOPROJECT_CMD_CONFIGx values should be GOPROJECT_ROOT related path. But you need to know that store configuration files into project repository is BAD PRACTICES (configuration files usually contain credentials, IPs, etc.). It's much more better to inject configuration file from outside (e.g. download from CI server). In this case set GOPROJECT_CMD_CONFIGx by URL value. Build scripts runs curl utility to download configuration files. It supports:

DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, Telnet, TFTP, SSL certificates, proxies, HTTP/2, cookies, user+password authentication (Basic, Plain, Digest, CRAM-MD5, NTLM, Negotiate and Kerberos) and more. Here are some examples:

Provide configuration file is stored into the same source code repository (not recommended for production):
GOPROJECT_CMD_CONFIG=config/settings.yaml

Provide configuration files are stored into the same source code repository (not recommended for production):
GOPROJECT_CMD_CONFIG1=config/db/db.yaml
GOPROJECT_CMD_CONFIG2=config/messaging/broker.json

Download configuration file via HTTPS:
GOPROJECT_CMD_CONFIG=https://config.server.com/myapp/settings.yaml

Download configuration files via HTTPS:
GOPROJECT_CMD_CONFIG1=https://config.server.com/myapp/db/db.yaml
GOPROJECT_CMD_CONFIG2=smb://config.server.com/messaging/broker.json -u "domain\username:passwd"

Notes:

  • If you have only one configuration file use GOPROJECT_CMD_CONFIG environment variable. If you have more that one configuration files use GOPROJECT_CMD_CONFIG1, GOPROJECT_CMD_CONFIG2, GOPROJECT_CMD_CONFIG3, etc. environment variables.
  • As you see above you can provide not URL only but other curl arguments like credentials. It very important to pass arguments after URL:
Correct:
GOPROJECT_CMD_CONFIG=smb://config.server.com/messaging/broker.json -u "domain\username:passwd"

Wrong:
GOPROJECT_CMD_CONFIG=-u "domain\username:passwd" smb://config.server.com/messaging/broker.json
  1. Leave other options with default values and click Create and wait while pod is created

[Optional] How to add health (liveness and readiness) checks

  1. Login to OpenShift console using browser (eg https://openshift.example.com:8443) with Developer account

  2. Open project1 project

  3. Click Applications -> Deployments

  4. Click golang1 in the list

  5. Select Configuration tab

  6. Click Add Health Checks

  7. Click Add Readiness Probe

  8. Set Path to '/healthz/ready' and leave other options with default values

  9. Click Add Liveness Probe

  10. Set Path to '/healthz/live' and leave other options with default values

  11. Click Save and wait while pod is created

Helper #1 - you can try golang template using S2I:

s2i build https://github.com/amsokol/openshift-golang-template.git amsokol/golang-openshift:1.9.2-1 golang1 -e GOPROJECT_ROOT=github.com/amsokol/openshift-golang-template/example-golang-dep -e GOPROJECT_CMD=cmd/server --context-dir /example-golang-dep

Helper #2 - how to export/edit template from OpenShift

  1. Login using oc as OpenShift administrator

  2. Run:

# oc get templates -n openshift
# oc edit template -n openshift nodejs-mongo-persistent
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].