-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from yunionio/feature/componets-cmd
add extra componets command
- Loading branch information
Showing
84 changed files
with
6,915 additions
and
6,934 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
GLOBALRC_FILE=${GLOBALRC_FILE:-/opt/cloud/workspace/globalrc} | ||
VARS_FILE=${VARS_FILE:-/opt/yunionsetup/vars} | ||
|
||
error_exit() { | ||
echo "Error: $1" | ||
exit 1 | ||
} | ||
|
||
check_file_exists() { | ||
local file=$1 | ||
if [ ! -f "$file" ]; then | ||
error_exit "file $file not exists" | ||
fi | ||
} | ||
|
||
new_cluster_yaml() { | ||
local rc_file=$GLOBALRC_FILE | ||
local vars_file=$VARS_FILE | ||
|
||
check_file_exists $rc_file | ||
check_file_exists $vars_file | ||
|
||
source $rc_file | ||
source $vars_file | ||
|
||
cat <<EOF | ||
--- | ||
# onecloud cluster core components config | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: default-cluster-config | ||
namespace: onecloud | ||
data: | ||
OnecloudClusterConfig: | | ||
apiVersion: onecloud.yunion.io/v1alpha1 | ||
kind: OnecloudClusterConfig | ||
apiGateway: | ||
username: "$YUNIONAPI_ADMIN_USER" | ||
password: "$YUNIONAPI_ADMIN_PASS" | ||
glance: | ||
db: | ||
database: "$MYSQL_DB_GLANCE" | ||
username: "$MYSQL_USER_GLANCE" | ||
password: "$MYSQL_PASS_GLANCE" | ||
username: "$GLANCE_ADMIN_USER" | ||
password: "$GLANCE_ADMIN_PASS" | ||
keystone: | ||
db: | ||
database: "$MYSQL_DB_KEYSTONE" | ||
username: "$MYSQL_USER_KEYSTONE" | ||
password: "$MYSQL_PASS_KEYSTONE" | ||
kubeserver: | ||
db: | ||
database: "$MYSQL_DB_KUBE" | ||
username: "$MYSQL_USER_KUBE" | ||
password: "$MYSQL_PASS_KUBE" | ||
username: "$YUNION_KUBE_SERVER_ADMIN_USER" | ||
password: "$YUNION_KUBE_SERVER_ADMIN_PASS" | ||
logger: | ||
db: | ||
database: "$MYSQL_DB_LOGGER" | ||
username: "$MYSQL_USER_LOGGER" | ||
password: "$MYSQL_PASS_LOGGER" | ||
username: "$LOGGER_ADMIN_USER" | ||
password: "$LOGGER_ADMIN_PASS" | ||
region: | ||
db: | ||
database: "$MYSQL_DB_REGION" | ||
username: "$MYSQL_USER_REGION" | ||
password: "$MYSQL_PASS_REGION" | ||
username: "$REGION_ADMIN_USER" | ||
password: "$REGION_ADMIN_PASS" | ||
webconsole: | ||
username: "$YUNION_WEBCONSOLE_ADMIN_USER" | ||
password: "$YUNION_WEBCONSOLE_ADMIN_PASS" | ||
yunionagent: | ||
db: | ||
database: "$MYSQL_DB_YUNIONAGENT" | ||
username: "$MYSQL_USER_YUNIONAGENT" | ||
password: "$MYSQL_PASS_YUNIONAGENT" | ||
username: "$YUNIONAGENT_ADMIN_USER" | ||
password: "$YUNIONAGENT_ADMIN_PASS" | ||
yunionconf: | ||
db: | ||
database: "$MYSQL_DB_YUNIONCONF" | ||
username: "$MYSQL_USER_YUNIONCONF" | ||
password: "$MYSQL_PASS_YUNIONCONF" | ||
username: "$YUNIONCONF_ADMIN_USER" | ||
password: "$YUNIONCONF_ADMIN_PASS" | ||
--- | ||
# onecloud cluster misc components config | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: default-cluster-components-config | ||
namespace: onecloud | ||
data: | ||
OnecloudComponentsConfig: | | ||
cloudmon: | ||
username: "$YUNION_CLOUDMON_DOCKER_USER" | ||
password: "$YUNION_CLOUDMON_DOCKER_PSWD" | ||
cloudwatcher: | ||
db: | ||
database: "$MYSQL_DB_CLOUDWATCHER" | ||
username: "$MYSQL_USER_CLOUDWATCHER" | ||
password: "$MYSQL_PASS_CLOUDWATCHER" | ||
username: "$YUNION_CLOUDWATCHER_DOCKER_USER" | ||
password: "$YUNION_CLOUDWATCHER_DOCKER_PSWD" | ||
itsm: | ||
encryptionKey: "$ITSM_ENCRYPTION_KEY" | ||
secondDatabase: "$MYSQL_DB_ITSM_SECONDARY" | ||
db: | ||
database: "$MYSQL_DB_ITSM_PRIMARY" | ||
username: "$MYSQL_USER_ITSM_PRIMARY" | ||
password: "$MYSQL_PASS_ITSM" | ||
username: "$YUNION_ITSM_DOCKER_USER" | ||
password: "$YUNION_ITSM_DOCKER_PSWD" | ||
meter: | ||
db: | ||
database: "$MYSQL_DB_METER" | ||
username: "$MYSQL_USER_METER" | ||
password: "$MYSQL_PASS_METER" | ||
username: "$YUNION_METER_DOCKER_USER" | ||
password: "$YUNION_METER_DOCKER_PSWD" | ||
meteralert: | ||
db: | ||
database: "$MYSQL_DB_METERALERT" | ||
username: "$MYSQL_USER_METERALERT" | ||
password: "$MYSQL_PASS_METERALERT" | ||
username: "$YUNION_METERALERT_DOCKER_USER" | ||
password: "$YUNION_METERALERT_DOCKER_PSWD" | ||
--- | ||
# default onecloud cluster | ||
apiVersion: onecloud.yunion.io/v1alpha1 | ||
kind: OnecloudCluster | ||
metadata: | ||
name: default | ||
namespace: onecloud | ||
spec: | ||
loadBalancerEndpoint: "$MANAGEMENT_IP" | ||
imageRepository: registry.cn-beijing.aliyuncs.com/yunionio | ||
mysql: | ||
host: "$MYSQL_HOST" | ||
password: "$MYSQL_ROOT_PASSWORD" | ||
port: $MYSQL_PORT | ||
username: root | ||
region: "$REGION" | ||
zone: "$ZONE" | ||
keystone: | ||
bootstrapPassword: "$SYSADMIN_PASSWORD" | ||
glance: | ||
nodeSelector: | ||
kubernetes.io/hostname: glance-node | ||
EOF | ||
} | ||
|
||
new_cluster_yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package cmd | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
componentphase "yunion.io/x/ocadm/pkg/phases/component" | ||
) | ||
|
||
func NewCmdComponent(out io.Writer) *cobra.Command { | ||
cmds := &cobra.Command{ | ||
Use: "component", | ||
Short: "Manage onecloud extra components", | ||
} | ||
cmds.AddCommand(componentphase.EnableCmd.GetCmd()) | ||
cmds.AddCommand(componentphase.DisableCmd.GetCmd()) | ||
cmds.AddCommand(componentphase.NewCmdConfig(out)) | ||
cmds.AddCommand(componentphase.NewCmdWeb()) | ||
return cmds | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package component | ||
|
||
import ( | ||
apps "k8s.io/api/apps/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
|
||
onecloud "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" | ||
) | ||
|
||
const ( | ||
CloudMonConfigTemplate = ` | ||
debug=false | ||
trace=false | ||
logging.level.com.yunion.cloudmon=INFO | ||
yunion.rc.auth.url={{.AuthURL}} | ||
yunion.rc.auth.domain={{.AuthDomain}} | ||
yunion.rc.auth.username={{.AuthUsername}} | ||
yunion.rc.auth.password={{.AuthPassword}} | ||
yunion.rc.auth.project={{.AuthProject}} | ||
yunion.rc.auth.region={{.Region}} | ||
yunion.rc.auth.cache-size=500 | ||
yunion.rc.auth.timeout=1000 | ||
yunion.rc.auth.debug=true | ||
yunion.rc.auth.insecure=true | ||
yunion.rc.auth.refresh-interval=300000 | ||
yunion.rc.async-job.initial-delay=2000 | ||
yunion.rc.async-job.fixed-rate=300000 | ||
yunion.rc.async-job.fixed-thread-pool=10 | ||
yunion.rc.influxdb.database=telegraf | ||
yunion.rc.influxdb.policy=30day_only | ||
yunion.rc.influxdb.measurement=instance | ||
yunion.rc.metrics.ins.providers=Aliyun,Azure,Aws,Qcloud,VMWare,Huawei,Openstack,Ucloud,ZStack | ||
yunion.rc.metrics.eip.providers=Aliyun,Qcloud | ||
` | ||
) | ||
|
||
var CloudMonComponent IComponent = NewCloudMon() | ||
|
||
type CloudMon struct { | ||
*BaseComponent | ||
} | ||
|
||
func NewCloudMon() *CloudMon { | ||
m := new(CloudMon) | ||
m.BaseComponent = NewBaseComponent(onecloud.ComponentType("cloudmon"), m) | ||
return m | ||
} | ||
|
||
func (m CloudMon) NewDeployment(oc *onecloud.OnecloudCluster) (*apps.Deployment, error) { | ||
cf := func(volMounts []corev1.VolumeMount) []corev1.Container { | ||
volMounts = SetJavaConfigVolumeMounts(volMounts) | ||
return []corev1.Container{ | ||
{ | ||
Name: "cloudmon", | ||
Image: GetImage(oc, m.GetComponentType(), ""), | ||
Env: []corev1.EnvVar{ | ||
{ | ||
Name: JAVA_APP_JAR, | ||
Value: "cloudmon.jar", | ||
}, | ||
}, | ||
VolumeMounts: volMounts, | ||
}, | ||
} | ||
} | ||
cType := m.GetComponentType() | ||
deploy, err := NewDefaultDeployment(cType, oc, NewVolumeHelper(oc, cType), cf) | ||
if err != nil { | ||
return nil, err | ||
} | ||
podSpec := &deploy.Spec.Template.Spec | ||
podSpec.Volumes = SetJavaConfigVolumes(podSpec.Volumes) | ||
return deploy, nil | ||
} | ||
|
||
func (m CloudMon) NewConfigMap(oc *onecloud.OnecloudCluster, cCfg *OnecloudComponentsConfig) (*corev1.ConfigMap, error) { | ||
cfg := cCfg.CloudmonConfig | ||
config := NewJavaBaseConfig(oc, cfg.Port, cfg.Username, cfg.Password) | ||
return NewConfigMapByTemplate(m.GetComponentType(), oc, CloudMonConfigTemplate, config) | ||
} | ||
|
||
func (m CloudMon) NewCloudUser(cfg *OnecloudComponentsConfig) *onecloud.CloudUser { | ||
return &cfg.CloudmonConfig.CloudUser | ||
} |
Oops, something went wrong.