Skip to content

Commit

Permalink
optimize yurttunnel server deployment and yurt app manager deployment… (
Browse files Browse the repository at this point in the history
openyurtio#435)

* optimize yurttunnel server deployment and yurt app manager deployment yaml for system arch, not write for amd64 forever

* Add a new parameter for yurtctl to control the system architecture

* help information describe more correct
  • Loading branch information
JameKeal authored Aug 27, 2021
1 parent 118b4ce commit 3b028c0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
28 changes: 22 additions & 6 deletions pkg/yurtctl/cmd/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import (
"strings"
"time"

"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/openyurtio/openyurt/pkg/projectinfo"
"github.com/openyurtio/openyurt/pkg/yurtctl/constants"
"github.com/openyurtio/openyurt/pkg/yurtctl/lock"
kubeutil "github.com/openyurtio/openyurt/pkg/yurtctl/util/kubernetes"
strutil "github.com/openyurtio/openyurt/pkg/yurtctl/util/strings"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -76,6 +77,7 @@ type ConvertOptions struct {
kubeConfigPath string
EnableAppManager bool
YurtAppManagerImage string
SystemArchitecture string
yurtAppManagerClientSet dynamic.Interface
}

Expand Down Expand Up @@ -141,6 +143,8 @@ func NewConvertCmd() *cobra.Command {
cmd.Flags().String("yurt-app-manager-image",
"openyurt/yurt-app-manager:v0.4.0",
"The yurt-app-manager image.")
cmd.Flags().String("system-architecture", "amd64",
"The system architecture of cloud nodes.")

return cmd
}
Expand Down Expand Up @@ -230,6 +234,12 @@ func (co *ConvertOptions) Complete(flags *pflag.FlagSet) error {
}
co.KubeadmConfPath = kcp

sa, err := flags.GetString("system-architecture")
if err != nil {
return err
}
co.SystemArchitecture = sa

// parse kubeconfig and generate the clientset
co.clientSet, err = kubeutil.GenClientSet(flags)
if err != nil {
Expand Down Expand Up @@ -362,7 +372,8 @@ func (co *ConvertOptions) RunConvert() (err error) {
if co.DeployTunnel {
if err = deployYurttunnelServer(co.clientSet,
co.CloudNodes,
co.YurttunnelServerImage); err != nil {
co.YurttunnelServerImage,
co.SystemArchitecture); err != nil {
err = fmt.Errorf("fail to deploy the yurt-tunnel-server: %s", err)
return
}
Expand All @@ -388,7 +399,8 @@ func (co *ConvertOptions) RunConvert() (err error) {
if co.EnableAppManager {
if err = deployYurtAppManager(co.clientSet,
co.YurtAppManagerImage,
co.yurtAppManagerClientSet); err != nil {
co.yurtAppManagerClientSet,
co.SystemArchitecture); err != nil {
err = fmt.Errorf("fail to deploy the yurt-app-manager: %s", err)
return
}
Expand Down Expand Up @@ -428,7 +440,8 @@ func (co *ConvertOptions) RunConvert() (err error) {
func deployYurtAppManager(
client *kubernetes.Clientset,
yurtappmanagerImage string,
yurtAppManagerClient dynamic.Interface) error {
yurtAppManagerClient dynamic.Interface,
systemArchitecture string) error {

// 1.create the YurtAppManagerCustomResourceDefinition
// 1.1 nodepool
Expand Down Expand Up @@ -483,6 +496,7 @@ func deployYurtAppManager(
constants.YurtAppManagerDeployment,
map[string]string{
"image": yurtappmanagerImage,
"arch": systemArchitecture,
"edgeWorkerLabel": projectinfo.GetEdgeWorkerLabelKey()}); err != nil {
return err
}
Expand All @@ -505,7 +519,8 @@ func deployYurtAppManager(
func deployYurttunnelServer(
client *kubernetes.Clientset,
cloudNodes []string,
yurttunnelServerImage string) error {
yurttunnelServerImage string,
systemArchitecture string) error {
// 1. create the ClusterRole
if err := kubeutil.CreateClusterRoleFromYaml(client,
constants.YurttunnelServerClusterRole); err != nil {
Expand Down Expand Up @@ -549,6 +564,7 @@ func deployYurttunnelServer(
constants.YurttunnelServerDeployment,
map[string]string{
"image": yurttunnelServerImage,
"arch": systemArchitecture,
"edgeWorkerLabel": projectinfo.GetEdgeWorkerLabelKey()}); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/yurtctl/constants/yurt-app-manager-tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ spec:
readOnly: true
nodeSelector:
openyurt.io/is-edge-worker: "false"
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/arch: {{.arch}}
beta.kubernetes.io/os: linux
priorityClassName: system-node-critical
terminationGracePeriodSeconds: 10
Expand Down
2 changes: 1 addition & 1 deletion pkg/yurtctl/constants/yurt-tunnel-server-tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ spec:
tolerations:
- operator: "Exists"
nodeSelector:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/arch: {{.arch}}
beta.kubernetes.io/os: linux
{{.edgeWorkerLabel}}: "false"
containers:
Expand Down

0 comments on commit 3b028c0

Please sign in to comment.