run as root

This commit is contained in:
w-mj 2023-02-17 15:08:14 +08:00
parent cd1da0dbc6
commit 5f6d11b972
No known key found for this signature in database
GPG Key ID: 3A2CB5BE2F835897
3 changed files with 11 additions and 0 deletions

View File

@ -75,6 +75,9 @@ func (a *AppModel) ContainerName() string {
} }
func (a *AppModel) ServiceName() string { func (a *AppModel) ServiceName() string {
if len(a.GetPorts()) == 0 {
return ""
}
if strings.TrimSpace(a.SvcName) != "" { if strings.TrimSpace(a.SvcName) != "" {
return fmt.Sprintf("%s-%s", a.NamePrefix(), a.SvcName) return fmt.Sprintf("%s-%s", a.NamePrefix(), a.SvcName)
} }

View File

@ -102,6 +102,9 @@ func (c *K8sClient) UpdateDeployment(app *AppModel) {
Ports: []v1.ContainerPort{ Ports: []v1.ContainerPort{
{ContainerPort: 80}, {ContainerPort: 80},
}, },
SecurityContext: &v1.SecurityContext{
RunAsUser: UnnamedPointer(int64(0)),
},
}}, }},
}, },
}, },

5
src/utils.go Normal file
View File

@ -0,0 +1,5 @@
package k8s_manager
func UnnamedPointer[T any](v T) *T {
return &v
}