mirror of
https://github.com/go-micro/go-micro.git
synced 2025-06-12 22:07:47 +02:00
Pass source of service to Deployment API; render templates properly (#969)
* Pass source of service to Deployment API; render templates properly * Enable Go modules by default. Honor runtime.Service.Exec * Make sure you remove go.mod and go.sum
This commit is contained in:
@ -38,6 +38,8 @@ type Kubernetes interface {
|
||||
|
||||
// DefaultService returns default micro kubernetes service definition
|
||||
func DefaultService(name, version string) *Service {
|
||||
log.Debugf("kubernetes default service: name: %s, version: %s", name, version)
|
||||
|
||||
Labels := map[string]string{
|
||||
"name": name,
|
||||
"version": version,
|
||||
@ -73,7 +75,9 @@ func DefaultService(name, version string) *Service {
|
||||
}
|
||||
|
||||
// DefaultService returns default micro kubernetes deployment definition
|
||||
func DefaultDeployment(name, version string) *Deployment {
|
||||
func DefaultDeployment(name, version, source string) *Deployment {
|
||||
log.Debugf("kubernetes default deployment: name: %s, version: %s, source: %s", name, version, source)
|
||||
|
||||
Labels := map[string]string{
|
||||
"name": name,
|
||||
"version": version,
|
||||
@ -102,7 +106,12 @@ func DefaultDeployment(name, version string) *Deployment {
|
||||
log.Debugf("Runtime could not parse build: %v", err)
|
||||
}
|
||||
|
||||
// TODO: change the image name here
|
||||
// enable go modules by default
|
||||
env := EnvVar{
|
||||
Name: "GO111MODULE",
|
||||
Value: "on",
|
||||
}
|
||||
|
||||
Spec := &DeploymentSpec{
|
||||
Replicas: 1,
|
||||
Selector: &LabelSelector{
|
||||
@ -114,8 +123,8 @@ func DefaultDeployment(name, version string) *Deployment {
|
||||
Containers: []Container{{
|
||||
Name: name,
|
||||
Image: DefaultImage,
|
||||
Env: []EnvVar{},
|
||||
Command: []string{"go", "run", "main.go"},
|
||||
Env: []EnvVar{env},
|
||||
Command: []string{"go", "run", source},
|
||||
Ports: []ContainerPort{{
|
||||
Name: name + "-port",
|
||||
ContainerPort: 8080,
|
||||
|
Reference in New Issue
Block a user