制作镜像需要cloud-localsd命令,默认没有安装,安装命令如下: yum install cloud-utils -y 编写user-data: cat << EOF > my-user-data #cloud-config chpasswd: list: | root:123456 expire: false ssh_pwauth: true EOF cloud-init也支持多种数据格式,我们使用的是cloud-config 格式,这种格式必须是以#cloud-config开头的yaml格式。 ls /mnt meta-data user-data cat user-data #cloud-config chpasswd: list: | root:123456 expire: false ssh_pwauth
set_hostname查询 metadata 中 hostname 信息,默认值就是 instance 的名字,配置指定hostname cloud-init: #cloud-config hostname : kvm_host01 fqdn: kvm_host01.example.com manage_etc_hosts: true 参数说明如下 cloud-init 只会读取以**#cloud-config #cloud-config ssh_pwauth: true disable_root: false chpasswd: list: | root:q1w2E#R$ centos 提供一个新注释 -R hostname:从known_hosta(第一次连接时就会在家目录.ssh目录下生产该密钥文件)文件中删除所有属于hostname的密钥 3,创建cloud init 虚拟机初始化文件 #cloud-config net-tools - tcpdump - sysstat timezone: Asia/Shanghai # manually set BOOTPROTO for static IP # older cloud-config
192.168.220.128:2181 config: server: git: uri: https://gitee.com/lm970585581/cloud-config 具体实例详见:https://gitee.com/lm970585581/cloud-config 码云上的配置信息 ?
禁用服务,需管理员权限chkconfig cloud-config offchkconfig cloud-final offchkconfig cloud-init offchkconfig cloud-init-local chkconfig cloud-config onchkconfig cloud-final onchkconfig cloud-init on chkconfig cloud-init-local on 禁用服务,需管理员权限systemctl disable cloud-config cloud-final cloud-init cloud-init-local 3. systemctl enable cloud-config cloud-final cloud-init cloud-init-local 准备工作 2:修改系统配置修改 fstab 配置查看 fstab
#cloud-config hostname: coreos users: - name: core ssh-authorized-keys: - ssh-rsa 网络我们安装后再配置也行,或者在cloud-config.yaml中配置好也行 #cloud-config hostname: coreos users: - name: core
CoreOS 配置工具已由 Ignition 代替 cloud-config。
CoreOS 已废弃组件 fleet => k8s cloud-config => Container Linux Config 转化为 ignition config 了解 CoreOS 请详细阅读本分类下的全部文章
probability: 1 # 抽样百分比 sender: type: web # 链路类型(kafka,rabbitmq) 实例代码: https://gitee.com/lm970585581/cloud-config
应用架构 服务名称 亮点 cloud-eureka:wrench:注册中心 安全的外套Security、实现高可用集群部署 config-repo:pencil2:配置管理 集中管理各环境的配置文件 cloud-config
Secret" secret.APIVersion = "v1" secret.ObjectMeta = metav1.ObjectMeta{ Name: "cloud-config } fmt.Printf(" * secret update: %v\n", result) err = secretClient.Delete(context.TODO(), "cloud-config
name ubuntu --cloud-init config.yaml 上面 config.yaml 则是容器的初始化配置文件,我们想在初始化容器的时候,自动下载安装 Node.js,内容如下: # cloud-config sudo -E bash - - sudo apt-get install -y nodejs runcmd可以指定容器 首次启动 时运行的命令 凡是用户自定义的cloud-init的配置文件,必须以#cloud-config
name ubuntu --cloud-init config.yaml 上面 config.yaml 则是容器的初始化配置文件,例如,我们想在初始化容器的时候,自动下载安装 Node.js,内容如下: #cloud-config sudo -E bash - - sudo apt-get install -y nodejs runcmd 可以指定容器首次启动时运行的命令 凡是用户自定义的cloud-init的配置文件,必须以#cloud-config
host-disk - name: cloudinit cloudInitNoCloud: userData: |- #cloud-config
90m,memory=1830Mi" MAX_PODS="--max-pods=253" CLOUD_PROVIDER="--cloud-provider=qcloud" CLOUD_CONFIG="--cloud-config cni-bin-dir=/opt/cni/bin/ --kube-reserved=cpu=90m,memory=1830Mi --max-pods=253 --cloud-provider=qcloud --cloud-config
2017/8:CoreOS 配置工具使用新的 Ignition 代替 cloud-config,旧的安装方法已经删除,但 GitHub 仍保留该配置文件。
}" "${API_SECURE_PORT}" kube-aggregator cloud_config_arg="--cloud-provider=${CLOUD_PROVIDER} --cloud-config true --cluster-cidr=10.1.0.0/16 " fi cloud_config_arg="--cloud-provider=${CLOUD_PROVIDER} --cloud-config cloud_config_arg+=" --external-cloud-volume-plugin=${CLOUD_PROVIDER}" cloud_config_arg+=" --cloud-config --runtime-config=admissionregistration.k8s.io/v1alpha1,settings.k8s.io/v1alpha1 --cloud-provider= --cloud-config --runtime-config=admissionregistration.k8s.io/v1alpha1,settings.k8s.io/v1alpha1 --cloud-provider= --cloud-config
cloud-init 20.1success: cloud-init -vsuccess: cloud-init enabledsuccess: cloud-init-local enabledsuccess: cloud-config
HttpStatus.UNAUTHORIZED.value()); } return null; } } 完整代码: https://gitee.com/lm970585581/cloud-config
fedora-cloud-container-disk-demo:latest - name: cloudinitdisk cloudInitNoCloud: userData: | #cloud-config
绑定浮动IP [jmeslso3cg.png] user-data:centos.config root@openstack-controller:~# more /tmp/centos.config #cloud-config power-state-change正常),产生了测试文件,修改了dns信息 user-data:ubuntu.config root@openstack-controller:~# more /tmp/ubuntu.config #cloud-config