smartxworks / cluster-api-provider-elf-static-ip

0 stars 2 forks source link

Add support for CAPE static ip management #1

Closed haijianyang closed 1 year ago

haijianyang commented 1 year ago
apiVersion: ipam.metal3.io/v1alpha1
kind: IPPool
metadata:
  name: ip-pool-1
  namespace: default
  labels:
spec:
  pools:
    - start: 10.255.160.10
      end: 10.255.160.20
      prefix: 16
      gateway: 10.255.0.1
  prefix: 16
  gateway: 10.255.0.1
  dnsServers: []
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
  labels:
    cluster.x-k8s.io/cluster-name: elfk8s8
  name: elfk8s8
  namespace: default
spec:
  clusterNetwork:
    pods:
      cidrBlocks:
      - 100.96.0.0/11
  controlPlaneRef:
    apiVersion: controlplane.cluster.x-k8s.io/v1beta1
    kind: KubeadmControlPlane
    name: elfk8s8-control-plane
  infrastructureRef:
    apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    kind: ElfCluster
    name: elfk8s8
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: ElfCluster
metadata:
  name: elfk8s8
  namespace: default
spec:
  cluster: dd1f408f-7715-48c1-a817-13c3568f1d93
  controlPlaneEndpoint:
    host: 10.255.160.7
    port: 6443
  tower:
    authMode: LOCAL
    password: root
    server: tower.com
    username: system-service
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: ElfMachineTemplate
metadata:
  name: elfk8s8-control-plane
  namespace: default
  labels:
    cluster.x-k8s.io/ip-pool-name: ip-pool-1
spec:
  template:
    spec:
      cloneMode: FastClone
      ha: true
      numCPUS: 4
      memoryMiB: 6144
      diskGiB: 20
      network:
        devices:
        - networkType: IPV4
          vlan: dd1f408f-7715-48c1-a817-13c3568f1d93_4cd00407-63ca-440b-80b7-ceacfccb8d08
      template: de6efbf8-fdae-4cad-9305-231c67d521a8
---
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlane
metadata:
  name: elfk8s8-control-plane
  namespace: default
spec:
  kubeadmConfigSpec:
    clusterConfiguration:
      apiServer:
        extraArgs: null
      clusterName: elfk8s8
      controllerManager:
        extraArgs: null
      imageRepository: registry.cn-hangzhou.aliyuncs.com/google_containers
    files:
    - content: |
        apiVersion: v1
        kind: Pod
        metadata:
          creationTimestamp: null
          name: kube-vip
          namespace: kube-system
        spec:
          containers:
          - args:
            - start
            env:
            - name: vip_arp
              value: "true"
            - name: vip_leaderelection
              value: "true"
            - name: vip_address
              value: '10.255.160.7'
            - name: vip_interface
              value: ens4
            - name: vip_leaseduration
              value: "15"
            - name: vip_renewdeadline
              value: "10"
            - name: vip_retryperiod
              value: "2"
            image: registry.smtx.io/kubesmart/kube-vip:v0.3.5
            imagePullPolicy: IfNotPresent
            name: kube-vip
            resources: {}
            securityContext:
              capabilities:
                add:
                - NET_ADMIN
                - SYS_TIME
            volumeMounts:
            - mountPath: /etc/kubernetes/admin.conf
              name: kubeconfig
          hostNetwork: true
          volumes:
          - hostPath:
              path: /etc/kubernetes/admin.conf
              type: FileOrCreate
            name: kubeconfig
        status: {}
      owner: root:root
      path: /etc/kubernetes/manifests/kube-vip.yaml
    initConfiguration:
      nodeRegistration:
        kubeletExtraArgs: null
        name: '{{ ds.meta_data.hostname }}'
    preKubeadmCommands:
    - hostname "{{ ds.meta_data.hostname }}"
    - echo "::1         ipv6-localhost ipv6-loopback" >/etc/hosts
    - echo "127.0.0.1   localhost" >>/etc/hosts
    - echo "127.0.0.1   {{ ds.meta_data.hostname }}" >>/etc/hosts
    - echo "{{ ds.meta_data.hostname }}" >/etc/hostname
    useExperimentalRetryJoin: true
  machineTemplate:
    infrastructureRef:
      apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
      kind: ElfMachineTemplate
      name: elfk8s8-control-plane
  replicas: 1
  version: v1.22.8
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
  name: elfk8s8-md-0
  namespace: default
spec:
  template:
    spec:
      clusterConfiguration:
        clusterName: elfk8s8
        imageRepository: registry.cn-hangzhou.aliyuncs.com/google_containers
      joinConfiguration:
        nodeRegistration:
          kubeletExtraArgs: null
          name: '{{ ds.meta_data.hostname }}'
      preKubeadmCommands:
      - hostname "{{ ds.meta_data.hostname }}"
      - echo "::1         ipv6-localhost ipv6-loopback" >/etc/hosts
      - echo "127.0.0.1   localhost" >>/etc/hosts
      - echo "127.0.0.1   {{ ds.meta_data.hostname }}" >>/etc/hosts
      - echo "{{ ds.meta_data.hostname }}" >/etc/hostname
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: ElfMachineTemplate
metadata:
  name: elfk8s8-worker
  namespace: default
  labels:
    cluster.x-k8s.io/ip-pool-name: ip-pool-1
spec:
  template:
    spec:
      cloneMode: FastClone
      ha: true
      numCPUS: 4
      memoryMiB: 6144
      network:
        devices:
        - networkType: IPV4
          vlan: dd1f408f-7715-48c1-a817-13c3568f1d93_4cd00407-63ca-440b-80b7-ceacfccb8d08
      template: de6efbf8-fdae-4cad-9305-231c67d521a8
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
  labels:
    cluster.x-k8s.io/cluster-name: elfk8s8
  name: elfk8s8-md-0
  namespace: default
spec:
  clusterName: elfk8s8
  replicas: 1
  selector:
    matchLabels: {}
  template:
    metadata:
      labels:
        cluster.x-k8s.io/cluster-name: elfk8s8
    spec:
      bootstrap:
        configRef:
          apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
          kind: KubeadmConfigTemplate
          name: elfk8s8-md-0
      clusterName: elfk8s8
      infrastructureRef:
        apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
        kind: ElfMachineTemplate
        name: elfk8s8-worker
      version: v1.22.8
image image
codecov-commenter commented 1 year ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (main@15315a8). Click here to learn what that means. The diff coverage is n/a.

@@           Coverage Diff           @@
##             main       #1   +/-   ##
=======================================
  Coverage        ?   72.46%           
=======================================
  Files           ?        1           
  Lines           ?      207           
  Branches        ?        0           
=======================================
  Hits            ?      150           
  Misses          ?       39           
  Partials        ?       18           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.