Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/TencentBlueKing/bk-bcs in…
Browse files Browse the repository at this point in the history
…to example-0717
  • Loading branch information
q15971095971 committed Jul 19, 2024
2 parents 0dcb316 + 868e07e commit 1e94495
Show file tree
Hide file tree
Showing 49 changed files with 3,459 additions and 2,986 deletions.
14 changes: 3 additions & 11 deletions bcs-ops/k8s/install_k8s_tools
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,10 @@ baseurl=${repo_url}
enabled=1
gpgcheck=0
[kubernetes-v1.27]
name=Kubernetes
baseurl=https://mirrors.tencent.com/kubernetes_new/core%3a/stable%3a/v1.27%3a/build/rpm/
enabled=1
gpgcheck=0
[kubernetes-v1.28]
name=Kubernetes
baseurl=https://mirrors.tencent.com/kubernetes_new/core%3a/stable%3a/v1.28%3a/build/rpm/
enabled=1
gpgcheck=0
EOF
curl https://mirrors.tencent.com/kubernetes_new/core%3a/stable%3a/v1.27%3a/build/rpm/isv%3akubernetes%3acore%3astable%3av1.27%3abuild.repo >> /etc/yum.repos.d/kubernetes.repo
echo "" >> /etc/yum.repos.d/kubernetes.repo
curl https://mirrors.tencent.com/kubernetes_new/core%3a/stable%3a/v1.28%3a/build/rpm/isv%3akubernetes%3acore%3astable%3av1.28%3abuild.repo >> /etc/yum.repos.d/kubernetes.repo
yum install -y -q yum-utils
yum-config-manager --add-repo "$ROOT_DIR/kubernetes.repo"
yum clean all
Expand Down
2 changes: 2 additions & 0 deletions bcs-ops/system/config_envfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ init_env() {
BK_HOME=${BK_HOME:-"/data/bcs"}
K8S_IPv6_STATUS=${K8S_IPv6_STATUS:-"Disable"}
LAN_IP=${LAN_IP:-}
LAN_DEV=${LAN_DEV:-}
LAN_IPv6=${LAN_IPv6:-}
BCS_SYSCTL=${BCS_SYSCTL:=1}
if [[ -z ${LAN_IP} ]] && [[ ${K8S_IPv6_STATUS,,} != "singlestack" ]]; then
Expand Down Expand Up @@ -239,6 +240,7 @@ render_env() {
# bcs config begin
## HOST
BK_HOME="${BK_HOME}"
LAN_DEV="${LAN_DEV}"
LAN_IP="${LAN_IP}"
$(
[[ ${K8S_IPv6_STATUS,,} == "dualstack" ]] \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func (r *ImageLoaderReconciler) Reconcile(ctx context.Context, req ctrl.Request)
return ctrl.Result{}, nil
}

logger.Info("start reconcile")
imageLoader := originImageLoader.DeepCopy()
newStatus, requeueTime, err := r.reconcileImageLoader(ctx, imageLoader)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ func (r *ImageLoaderReconciler) cleanJobs(ctx context.Context,
func (r *ImageLoaderReconciler) createJobsIfNeed(ctx context.Context,
loader *tkexv1alpha1.ImageLoader, baseJob *batchv1.Job) error {
for i := range loader.Spec.Images {
logger.Info(fmt.Sprintf("create job for %d image", i))
job := &batchv1.Job{}
err := r.Get(ctx, types.NamespacedName{Namespace: loader.Namespace,
Name: getJobName(loader, i)}, job)
if err != nil && errors.IsNotFound(err) {
logger.Info(fmt.Sprintf("create job for %d image", i))
err = r.createJob(ctx, loader, baseJob, i)
if err != nil {
return err
Expand All @@ -154,6 +154,7 @@ func (r *ImageLoaderReconciler) createJobsIfNeed(ctx context.Context,

func (r *ImageLoaderReconciler) createJob(ctx context.Context, loader *tkexv1alpha1.ImageLoader,
baseJob *batchv1.Job, index int) error {
// some field may be nil after deepcopy
job := baseJob.DeepCopy()
modifyJob(job, loader, index)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,22 @@ func (r *ImageLoaderReconciler) handleAllNode(ctx context.Context, job *batchv1.

func modifyJob(job *batchv1.Job, loader *tkexv1alpha1.ImageLoader, index int) {
job.Name = getJobName(loader, index)
if job.Annotations == nil {
job.Annotations = make(map[string]string)
}
job.Annotations[LoaderJobNameKey] = job.Name
if job.Spec.Template.Labels == nil {
job.Spec.Template.Labels = make(map[string]string)
}
job.Spec.Template.Labels[LoaderJobNameKey] = job.Name
job.Spec.Template.Spec.Containers[0].Image = loader.Spec.Images[index]
job.Spec.Template.Spec.Containers[0].Command = []string{
"echo", "pull " + loader.Spec.Images[index],
}
// ensure the job runs one pod on each node
if job.Spec.Template.Spec.Affinity == nil {
job.Spec.Template.Spec.Affinity = &corev1.Affinity{}
}
job.Spec.Template.Spec.Affinity.PodAntiAffinity = &corev1.PodAntiAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ func (rc *RuleConverter) getServiceBackendsFromPods(

var retBackends []networkextensionv1.ListenerBackend
for _, pod := range podList {
if len(pod.Status.PodIP) == 0 || pod.Status.Phase != k8scorev1.PodRunning {
if !rc.checkPodNeedHandle(pod) {
continue
}
backendWeight := rc.getPodWeight(pod, weight)
Expand Down Expand Up @@ -624,3 +624,25 @@ func (rc *RuleConverter) patchPodLBWeightReady(pod *k8scorev1.Pod) error {
}
return rc.cli.Patch(context.TODO(), updatePod, client.RawPatch(k8stypes.MergePatchType, patchData))
}

// return true if pod need to be handled
func (rc *RuleConverter) checkPodNeedHandle(pod *k8scorev1.Pod) bool {
if len(pod.Status.PodIP) == 0 || pod.Status.Phase != k8scorev1.PodRunning {
return false
}

containerAllDown := true
for _, containerStatus := range pod.Status.ContainerStatuses {
// if terminated is nil, means container is running or waiting
if containerStatus.State.Terminated == nil {
containerAllDown = false
break
}
}
// if all of pod's containers all down, no need to handle the pod
if containerAllDown {
blog.Infof("pod[%s/%s] containers all down, skip...", pod.GetNamespace(), pod.GetName())
return false
}
return true
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

// GenPortBindingLabel 生成portBinding label, 当长度超过63时(k8s限制), 将截取前50位+md5值的前13位作为label key
func GenPortBindingLabel(namespace string, name string) string {
func GenPortBindingLabel(name string, namespace string) string {
result := fmt.Sprintf(networkextensionv1.PortPoolBindingLabelKeyFormat, name, namespace)
if len(result) > 63 {
hash := fmt.Sprintf("%x", md5.Sum([]byte(result)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,21 +279,9 @@ func (ppih *PortPoolItemHandler) ensureListeners(region, lbID string, item *nete
blog.Warnf("create listener %s failed, err %s", tmpName, inErr.Error())
}
} else {
// 部分旧版本监听器labels不全需要补齐
if !checkListenerLabels(listener.Labels, ppih.PortPoolName, item.ItemName) {
poolNameLabel := common.GetPortPoolListenerLabelKey(ppih.PortPoolName, item.ItemName)
listener.Labels[poolNameLabel] = netextv1.LabelValueForPortPoolItemName
listener.Labels[netextv1.LabelKeyForOwnerKind] = constant.KindPortPool
listener.Labels[netextv1.LabelKeyForOwnerName] = ppih.PortPoolName
if inErr := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
return ppih.K8sClient.Update(context.Background(), listener,
&client.UpdateOptions{},
)
}); inErr != nil {
blog.Warnf("update listener %s failed, err %s", tmpName, inErr.Error())
}
}
if !reflect.DeepEqual(listener.Spec.Certificate, item.Certificate) || !reflect.DeepEqual(listener.
if !checkListenerLabels(listener.Labels, ppih.PortPoolName,
item.ItemName) || !reflect.DeepEqual(listener.Spec.Certificate,
item.Certificate) || !reflect.DeepEqual(listener.
Spec.ListenerAttribute, ppih.ListenerAttr) {
if err = retry.RetryOnConflict(retry.DefaultBackoff, func() error {
li := &netextv1.Listener{}
Expand All @@ -303,6 +291,11 @@ func (ppih *PortPoolItemHandler) ensureListeners(region, lbID string, item *nete
}, li); inErr != nil {
return inErr
}
// 部分旧版本监听器labels不全需要补齐
poolNameLabel := common.GetPortPoolListenerLabelKey(ppih.PortPoolName, item.ItemName)
li.Labels[poolNameLabel] = netextv1.LabelValueForPortPoolItemName
li.Labels[netextv1.LabelKeyForOwnerKind] = constant.KindPortPool
li.Labels[netextv1.LabelKeyForOwnerName] = ppih.PortPoolName

li.Spec.Certificate = item.Certificate
li.Spec.ListenerAttribute = ppih.ListenerAttr
Expand Down
2 changes: 1 addition & 1 deletion bcs-services/bcs-bscp/cmd/api-server/cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var migrateInitApigatewayCmd = &cobra.Command{

logs.InitLogger(cc.ApiServer().Log.Logs())

if err := apigw.ReleaseSwagger(cc.ApiServer().Esb, cc.AuthServer().ApiGateway, "zh",
if err := apigw.ReleaseSwagger(cc.ApiServer().Esb, cc.ApiServer().ApiGateway, "zh",
fmt.Sprintf("%s+%s", version.GITTAG, time.Now().Format("20060102150405"))); err != nil {
fmt.Println(err)
return
Expand Down
1 change: 1 addition & 0 deletions bcs-services/bcs-bscp/pkg/cc/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type ApiServerSetting struct {
Repo Repository `yaml:"repository"`
BKNotice BKNotice `yaml:"bkNotice"`
Esb Esb `yaml:"esb"`
ApiGateway ApiGateway `yaml:"apiGateway"`
FeatureFlags FeatureFlags `yaml:"featureFlags"`
}

Expand Down
54 changes: 44 additions & 10 deletions bcs-services/bcs-bscp/ui/src/components/head.vue
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,36 @@
const logList = ref<IVersionLogItem[]>([]);
const isShowVersionLog = ref(false);
// @ts-ignore
const modules = import.meta.glob('../../../docs/changelog/zh_CN/*.md', {
as: 'raw',
eager: true,
// const modules = import.meta.glob('../../../docs/changelog/zh_CN/*.md', {
// as: 'raw',
// eager: true,
// });
// const modules = import.meta.glob('../../../docs/changelog/en_US/*.md', {
// as: 'raw',
// eager: true,
// });
const logModules = computed(() => {
if (locale.value === 'zh-cn') {
// @ts-ignore
return import.meta.glob('../../../docs/changelog/zh_CN/*.md', {
as: 'raw',
eager: true,
});
}
// @ts-ignore
return import.meta.glob('../../../docs/changelog/en_US/*.md', {
as: 'raw',
eager: true,
});
});
Object.keys(modules).forEach((path) => {
Object.keys(logModules.value).forEach((path) => {
const separator = locale.value === 'zh-cn' ? 'CN/' : 'US/';
logList.value!.push({
title: path.split('CN/')[1].split('_')[0],
date: path.split('CN/')[1].split('_')[1].slice(0, -3),
detail: md.render(modules[path]),
title: path.split(separator)[1].split('_')[0],
date: path.split(separator)[1].split('_')[1].slice(0, -3),
// @ts-ignore
detail: md.render(logModules.value[path]),
});
});
Expand All @@ -334,9 +355,22 @@
const featuresContent = ref('');
const isShowFeatures = ref(false);
// @ts-ignore
const module = import.meta.glob('../../../docs/features/features.md', { as: 'raw', eager: true });
Object.keys(module).forEach((path) => {
featuresContent.value = md.render(module[path]);
const featuresModule = computed(() => {
if (locale.value === 'zh-cn') {
// @ts-ignore
return import.meta.glob('../../../docs/features/features.md', {
as: 'raw',
eager: true,
});
}
// @ts-ignore
return import.meta.glob('../../../docs/features/features_en.md', {
as: 'raw',
eager: true,
});
});
Object.keys(featuresModule.value).forEach((path) => {
featuresContent.value = md.render(featuresModule.value[path]);
});
const handleLoginOut = () => {
loginOut();
Expand Down
2 changes: 1 addition & 1 deletion bcs-services/bcs-bscp/ui/src/components/version-log.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<slot>
<span class="item-title">{{ item.title }}</span>
<span class="item-date">{{ item.date }}</span>
<span v-if="index === 0" class="item-current">{{ t('当前版本') }}</span>
<span v-if="index === 0" class="item-current">{{ t('log_当前版本') }}</span>
</slot>
</li>
</ul>
Expand Down
13 changes: 10 additions & 3 deletions bcs-services/bcs-bscp/ui/src/i18n/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default {
没有匹配到配置项: 'No configuration item was matched',
请先在左侧表单设置关联规则并预览: 'Please first set the association rules in the left form and preview',
删除服务成功: 'Service deleted successfully',
log_当前版本: 'Version',

// 导航栏
服务配置中心: 'BSCP',
Expand Down Expand Up @@ -288,7 +289,7 @@ export default {
移除模板套餐成功: 'Template package removed successfully',
删除配置文件成功: 'Configuration file deleted successfully',
编辑配置文件: 'Edit configuration file',
目标版本: 'target version',
目标版本: 'Target version',
当前最新为: 'The current latest is',
模板版本更新成功: 'Template version updated successfully',
查看配置文件: 'View configuration file',
Expand Down Expand Up @@ -460,6 +461,10 @@ export default {
'单文件大小不能超过{n}M': 'The file size cannot exceed {n} MB',
'压缩包大小不能超过{n}GB': 'The compressed package size cannot exceed {n} GB',
重置: 'Reset',
'请确保文件大小不超过 {n} MB': 'Please ensure that the file size does not exceed {n} MB',
'文件上传失败,请重新上传文件': 'File upload failed, please re-upload the file',
新版本已生成: 'New version has been generated',
未上线版本的分组: 'Group of unlaunched versions',

// 分组管理
新增分组: 'New group',
Expand Down Expand Up @@ -489,6 +494,7 @@ export default {
'服务名称/服务版本': 'Service name/Service version',
服务版本: 'Service version',
'未在配置文件中检测到变量,请确保配置文件中包含变量后再尝试设置变量': 'Variable not detected in the configuration file. Please ensure the configuration file includes the variable before attempting to set it.',
标签最大数量为5个: 'Label maximum number is 5',

// 全局变量
配置模板与变量: 'Configure templates and variables',
Expand All @@ -515,6 +521,7 @@ export default {
'变量名 变量类型 变量值 变量描述(可选)': 'Variable name Variable type Variable value Variable Description (optional)',
' bk_bscp_nginx_port number 8080 nginx端口': ' bk_bscp_nginx_port number 8080 nginx port',
导出变量: 'Export variables',
全局变量: 'Global variables',

// 配置模板
'配置模板用于同一业务下服务间配置文件复用,可以在创建服务配置时引用配置模板。': 'Configuration templates are used to reuse configuration files between services under same services, and can be referenced when creating service configurations.',
Expand Down Expand Up @@ -841,8 +848,8 @@ export default {
最后心跳时间: 'Last heartbeat time',
查询: 'Search',
标签: 'label',
当前配置版本: 'current configuration version',
目标配置版本: 'target configuration version',
当前配置版本: 'Current configuration version',
目标配置版本: 'Target configuration version',
最近一次拉取配置状态: 'Last pull configuration status',
成功: 'success',
失败: 'failed',
Expand Down
6 changes: 6 additions & 0 deletions bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default {
请输入服务名: '请输入服务名',
同时会删除服务密钥对服务的关联规则: '同时会删除服务密钥对服务的关联规则',
删除服务成功: '删除服务成功',
log_当前版本: '当前版本',

// 导航栏
服务配置中心: '服务配置中心',
Expand Down Expand Up @@ -459,6 +460,10 @@ export default {
'单文件大小不能超过{n}M': '单文件大小不能超过{n}M',
'压缩包大小不能超过{n}GB': '压缩包大小不能超过{n}GB',
重置: '重置',
'请确保文件大小不超过 {n} MB': '请确保文件大小不超过 {n} MB',
'文件上传失败,请重新上传文件': '文件上传失败,请重新上传文件',
新版本已生成: '新版本已生成',
未上线版本的分组: '未上线版本的分组',

// 分组管理
新增分组: '新增分组',
Expand Down Expand Up @@ -487,6 +492,7 @@ export default {
上线服务: '上线服务',
'服务名称/服务版本': '服务名称/服务版本',
服务版本: '服务版本',
标签最大数量为5个: '标签最大数量为5个',

// 全局变量
配置模板与变量: '配置模板与变量',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
:label="t('客户端组件版本')"
:width="128"
prop="client.spec.client_version"></bk-table-column>
<bk-table-column :label="t('操作')" :width="160" fixed="right">
<bk-table-column :label="t('操作')" :width="locale === 'zh-cn' ? 160 : 230" fixed="right">
<template #default="{ row }">
<div v-if="row.client">
<bk-button theme="primary" text @click="handleShowPullRecord(row.client.attachment.uid, row.client.id)">
Expand Down Expand Up @@ -253,7 +253,7 @@
import RetryBtn from './components/retry-btn.vue';
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
const { t, locale } = useI18n();
const clientStore = useClientStore();
const { searchQuery } = storeToRefs(clientStore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
@toggle-full-screen="isOpenFullScreen = !isOpenFullScreen" />
</template>
<template #head-suffix>
<bk-select v-model="selectTime" class="time-selector" :filterable="false" :clearable="false">
<bk-select
v-model="selectTime"
:class="['time-selector', { 'en-time-selector': locale === 'en' }]"
:filterable="false"
:clearable="false">
<bk-option v-for="item in selectorTimeList" :id="item.value" :key="item.value" :name="item.label" />
</bk-select>
</template>
Expand Down Expand Up @@ -63,7 +67,7 @@
import { useI18n } from 'vue-i18n';
import { Share } from 'bkui-vue/lib/icon';
const { t } = useI18n();
const { t, locale } = useI18n();
const router = useRouter();
Expand Down Expand Up @@ -311,6 +315,9 @@
:deep(.bk-input) {
height: 26px;
}
&.en-time-selector {
width: 120px;
}
}
.fullscreen {
position: fixed;
Expand Down
Loading

0 comments on commit 1e94495

Please sign in to comment.