作者: domain

  • Lens 安装 kube-state-metrics 超时

    使用 Lens 安装 kube-state-metrics 时发现,镜像是从 k8s.gcr.io/kube-state-metrics/kube-state-metrics:v2.0.0 拉取的,国内的 TKE 集群拉取会超时。可以直接修改 Deployment 的镜像为:ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:v2.0.0。

    也可以从 k8s-gcrio.azureedge.net/kube-state-metrics/kube-state-metrics:v2.0.0 拉取。

    如果只有单节点而且不想修改 Deployment 的话,可以在对应机器上拉取国内镜像,然后使用对应运行时的镜像工具修改镜像 Tag。以 containerd 为例:

    crictl pull ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:v2.0.0
    ctr -n k8s.io image tag ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:v2.0.0 k8s.gcr.io/kube-state-metrics/kube-state-metrics:v2.0.0

  • 修改 Kubernetes 默认 StorageClass

    今天部署一个应用的时候卡在新建 PVC,看到报错:

    Internal error occurred: 2 default StorageClasses were found

    编辑那个现在是默认,但是实际上不需要是默认的 sc,把:

    storageclass.kubernetes.io/is-default-class

    注解改为 false,或直接删除。

    引用

    https://kubernetes.io/docs/tasks/administer-cluster/change-default-storage-class/

  • 增加 Kubernetes CoreDNS Hosts 以自定义解析结果

    编辑 kube-system 中的 coredns 这个 ConfigMap,可以:

    kubectl edit configmap coredns -n kube-system

    在 Corefile 的:

    .:53 {
      ... ...
    }

    添加:

    hosts {
      127.0.0.1 localhost
      fallthrough
    }

    如果需要对单个 Pod 级别生效,可以设置 hostAliases。见:

    https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/#adding-additional-entries-with-hostaliases

    引用

    https://stackoverflow.com/a/65283959
    https://coredns.io/plugins/hosts/

    我还发现了什么好玩的

    由于不知道 Corefile 语法高亮应该用啥,于是看到了:

    https://coredns.io/2017/07/23/corefile-explained/

  • 下载“来自设备制造商的 HEVC 视频扩展”

    在浏览器中访问:

    ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq

  • 修改 WordPress Twenty Fifteen 主题页脚以增加备案号

    感觉 Twenty Fifteen(2015)这个主题挺简洁,甚合我意。不过发现这个主题页脚没有提供可视化的设置,于是乎只能在主题编辑器上面看看页脚的源码(footer.php)怎么写的:

    <?php
    /**
     * The template for displaying the footer
     *
     * Contains the closing of the "site-content" div and all content after.
     *
     * @package WordPress
     * @subpackage Twenty_Fifteen
     * @since Twenty Fifteen 1.0
     */
    ?>
    
    	</div><!-- .site-content -->
    
    	<footer id="colophon" class="site-footer">
    		<div class="site-info">
    			<?php
    				/**
    				 * Fires before the Twenty Fifteen footer text for footer customization.
    				 *
    				 * @since Twenty Fifteen 1.0
    				 */
    				do_action( 'twentyfifteen_credits' );
    			?>
    			<?php
    			if ( function_exists( 'the_privacy_policy_link' ) ) {
    				the_privacy_policy_link( '', '<span role="separator" aria-hidden="true"></span>' );
    			}
    			?>
    			<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'twentyfifteen' ) ); ?>" class="imprint">
    				<?php
    				/* translators: %s: WordPress */
    				printf( __( 'Proudly powered by %s', 'twentyfifteen' ), 'WordPress' );
    				?>
    			</a>
    		</div><!-- .site-info -->
    	</footer><!-- .site-footer -->
    
    </div><!-- .site -->
    
    <?php wp_footer(); ?>
    
    </body>
    </html>
    

    注意到第 23 行这里提供了一个钩子可以注入代码,如果在子主题里使用这个方法注入的话,就不需要修改原主题页脚的代码,这样的话代码量小,后期升级兼容性也更好。

    那么就新建一个子主题,在 functions.php 这里加载:

    add_action( 'twentyfifteen_credits', 'custom_footer_provider' );
    function custom_footer_provider() {
    	printf( '<a class="imprint" href="%s" target="_blank">%s</a>', 'https://beian.miit.gov.cn/', '粤ICP备XXX号-X' );
    }

    此时页脚已经可以显示备案号了,不过和原有的“自豪地采用WordPress”文字挤在一起,不太好看。注意到这两个元素其实是在一个 <div class="site-info"></div> 里的,那么只需要在 style.css 里面设置一下 flex 布局:

    .site-info {
    	display: flex;
    	justify-content: space-between;
    }

    此时两个文字已经贴靠两边显示了。

  • PowerShell Base64 编码与解码

    [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(''))
    [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String(''))

  • JetBrains Quest (March 11, 2020) Write-Up

    第二波解谜,可以在 https://twitter.com/jetbrains/status/1237694815283879943 找到。

    给出了一段字符串:

    .spleh A+lrtC/dmC .thgis fo tuo si ti semitemos ,etihw si txet nehw sa drah kooL .tseretni wohs dluohs uoy ecalp a si ,dessecorp si xat hctuD erehw esac ehT .sedih tseuq fo txen eht erehw si ,deificeps era segaugnal cificeps-niamod tcudorp ehT

    仔细看一下就会发现是倒序

    比较明显是倒序的,先尝试复原:

    fun main() {
        val string = ".spleh A+lrtC/dmC .thgis fo tuo si ti semitemos ,etihw si txet nehw sa drah kooL .tseretni wohs dluohs uoy ecalp a si ,dessecorp si xat hctuD erehw esac ehT .sedih tseuq fo txen eht erehw si ,deificeps era segaugnal cificeps-niamod tcudorp ehT"
        print(string.reversed())
    }

    会得到:The product domain-specific languages are specified, is where the next of quest hides. The case where Dutch tax is processed, is a place you should show interest. Look hard as when text is white, sometimes it is out of sight. Cmd/Ctrl+A helps.

    比较明显:

    来到 MPS: The Domain-Specific Language Creator by JetBrains,能发现这里有个:

    打开报告,根据提示,全选来尝试看到白色的文字:

    复制出来可以得到:This is our 20th year as a company, we have shared numbers in our JetBrains Annual report, sharing the section with 18,650 numbers will progress your quest.

    所以前往 JetBrains 2019 Annual Highlights – Celebrating 20 Years!,找了半天没发现哪里有 18650,后面才发现原来是这个加起来刚好是 18650:

    进去后慢慢翻,有个图片:

    有一段火星文?可以慢慢看,也可以看看图片的 alt 属性:

    能勉强看出来是:Did you know JetBrains is always hiring? Check out the kareers(careers) page and see if there is a job for you or a quest challenge to go further at least.

    在招聘页面能找到这个 Fearless Quester 在 https://www.jetbrains.com/careers/jobs/fearless-quester-356/,但是忘记截图了,现在已经 404 了,有点尴尬。

    一直觉得自己执行力好差啊…还是要想办法做到今日事今日毕才行…

    根据提示后续要到 Game Development Tools by JetBrains,用科乐美秘技触发,有一个打砖块游戏,打完砖块就出现了:

  • Windows 10 下使用 Windows+Shift+S 截图

    好消息,好消息!如果你正在使用较新的 Windows 10,那么截图只要:Windows 徽标键 +Shift+S 即可触发截图和草图应用来抓取矩形截图、任意形状截图、窗口截图或是全屏幕截图;Windows 徽标键 +PrtSc 即可触发截图和草图应用直接抓取全屏幕截图。不用再为了截图打开微信或 QQ 啦。

    如果你觉得这个快捷键比较难按,你可以在设置->轻松使用->键盘中修改:

    什么?你说我火星了?好像不是我,是我的朋友们…(无中生友ing)

    好,来说说这个功能。根据此文章 Why doesn’t the screen clipping tool work anymore? – OneNote 所述,该热键本是 OneNote 用户用于截图的,自 Windows 10 创意者更新(也就是1703)后,由截图与草图应用接管。相关文章还包括:What’s New in Windows 10’s Creators UpdateHow to take and annotate screenshots on Windows 10

    还要注意的是,根据 Snip & Sketch…. : Windows10 – Reddit。截取屏幕后,你通常直接从剪贴板中取得图片,但是在:%LOCALAPPDATA%\Packages\Microsoft.Windows.ShellExperienceHost_cw5n1h2txyewy\TempState\ScreenClip 路径下仍然保存有图片的副本(也就是 C:\Users\%USERNAME%\AppData\Local\Packages\Microsoft.Windows.ShellExperienceHost_cw5n1h2txyewy\TempState\ScreenClip)。可能有隐私泄露风险,请务必注意。

  • 普通用户不需要 sudo 使用 Docker

    大多数情况下,普通用户使用 Docker 都需要使用 sudo 进行提权,否则可能要切换到 root 用户才可直接使用。其实只需要将当前用户加入 docker 用户组即可。

    The docker group grants privileges equivalent to the root user. For details on how this impacts security in your system, see Docker Daemon Attack Surface.

    Post-installation steps for Linux | Docker Documentation

    正常情况下应该已经存在docker用户组了,如果没有则需要:

    sudo groupadd docker

    来添加一个名为docker的用户组。

    然后就可以将当前用户加入docker用户组:

    sudo usermod -aG docker $USER

    或者:

    sudo gpasswd -a $USER docker

    注销后重新登录即可生效。按文档,对于有图形界面的Linux,应该注销再登录即可,否则应该完全重启。如果不方便注销,可以尝试:

    newgrp docker

    此时应该可以不需要sudo来使用Docker了。

    发现版本19.03起有一个实验性特性,以非root用户运行Docker守护进程:

    dockerd-rootless.sh --experimental

    引用

    Post-installation steps for Linux | Docker Documentation
    How can I use docker without sudo? – Ask Ubuntu
    Docker security | Docker Documentation

  • Chrome 离线安装

    推荐同学用 Google Chrome 作为日常的浏览器,但是他表示很难下载成功。为了省事,我决定直接弄个离线安装包给他。

    直接搜索 chrome offline installer,找到了官方文档:下載及安裝 Google Chrome – 電腦 – Google Chrome說明。文中说明了在离线状态下安装 Chrome,需要在联网的主机上下载备用Chrome安装程序,就是我想要的离线安装包了。

    只要打开上述链接再点击下载 Chrome 就可以得到离线安装包了。

    仔细看了一下那个链接,其实本质上只是在 Chrome 的官方网址 https://www.google.com/chrome/ 后面加上 ?standalone=1 而已。即:https://www.google.com/chrome/?standalone=1

    引用

    Google Chrome 离线安装包的官方下载地址是什么? – 知乎