|
| 1 | +package v1beta1 |
| 2 | + |
| 3 | +import ( |
| 4 | + corev1 "k8s.io/api/core/v1" |
| 5 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 6 | +) |
| 7 | + |
| 8 | +type InterfaceType string |
| 9 | + |
| 10 | +const ( |
| 11 | + // InterfaceTypePublic is a public network interface. |
| 12 | + InterfaceTypePublic InterfaceType = "Public" |
| 13 | + // InterfaceTypePrivate is a private network interface. |
| 14 | + InterfaceTypePrivate InterfaceType = "Private" |
| 15 | +) |
| 16 | + |
| 17 | +// CloudscaleMachineProviderSpec is the type that will be embedded in a Machine.Spec.ProviderSpec field |
| 18 | +// for a cloudscale virtual machine. It is used by the cloudscale machine actuator to create a single Machine. |
| 19 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 20 | +type CloudscaleMachineProviderSpec struct { |
| 21 | + metav1.TypeMeta `json:",inline"` |
| 22 | + |
| 23 | + // ObjectMeta is the standard object's metadata. |
| 24 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 25 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 26 | + |
| 27 | + // UserDataSecret is a reference to a secret that contains the UserData to apply to the instance. |
| 28 | + // The secret must contain a key named userData. The value is evaluated using Jsonnet; it can be either pure JSON or a Jsonnet template. |
| 29 | + // The Jsonnet template has access to the following variables: |
| 30 | + // - std.extVar('context').machine: the Machine object. The name can be accessed via std.extVar('context').machine.metadata.name for example. |
| 31 | + // - std.extVar('context').data: all keys from the UserDataSecret. For example, std.extVar('context').data.foo will access the value of the key foo. |
| 32 | + // +optional |
| 33 | + UserDataSecret *corev1.LocalObjectReference `json:"userDataSecret,omitempty"` |
| 34 | + // TokenSecret is a reference to the secret with the cloudscale API token. |
| 35 | + // The secret must contain a key named token. |
| 36 | + // If no token is provided, the operator will try to use the default token from CLOUDSCALE_API_TOKEN. |
| 37 | + // +optional |
| 38 | + TokenSecret *corev1.LocalObjectReference `json:"tokenSecret,omitempty"` |
| 39 | + |
| 40 | + // BaseDomain is the base domain to use for the machine. |
| 41 | + // +optional |
| 42 | + BaseDomain string `json:"baseDomain,omitempty"` |
| 43 | + // Zone is the zone in which the machine will be created. |
| 44 | + Zone string `json:"zone"` |
| 45 | + // AntiAffinityKey is a key to use for anti-affinity. If set, the machine will be placed in different cloudscale server groups based on this key. |
| 46 | + // The machines are automatically distributed across server groups with the same key. |
| 47 | + // +optional |
| 48 | + AntiAffinityKey string `json:"antiAffinityKey,omitempty"` |
| 49 | + // ServerGroups is a list of UUIDs identifying the server groups to which the new server will be added. |
| 50 | + // Used for anti-affinity. |
| 51 | + // https://www.cloudscale.ch/en/api/v1#server-groups |
| 52 | + ServerGroups []string `json:"serverGroups,omitempty"` |
| 53 | + // Tags is a map of tags to apply to the machine. |
| 54 | + Tags map[string]string `json:"tags"` |
| 55 | + // Flavor is the flavor of the machine. |
| 56 | + Flavor string `json:"flavor"` |
| 57 | + // Image is the base image to use for the machine. |
| 58 | + // For images provided by cloudscale: the image’s slug. |
| 59 | + // For custom images: the image’s slug prefixed with custom: (e.g. custom:ubuntu-foo), or its UUID. |
| 60 | + // If multiple custom images with the same slug exist, the newest custom image will be used. |
| 61 | + // https://www.cloudscale.ch/en/api/v1#images |
| 62 | + Image string `json:"image"` |
| 63 | + // RootVolumeSizeGB is the size of the root volume in GB. |
| 64 | + RootVolumeSizeGB int `json:"rootVolumeSizeGB"` |
| 65 | + // SSHKeys is a list of SSH keys to add to the machine. |
| 66 | + SSHKeys []string `json:"sshKeys"` |
| 67 | + // UseIPV6 is a flag to enable IPv6 on the machine. |
| 68 | + // Defaults to true. |
| 69 | + UseIPV6 *bool `json:"useIPV6,omitempty"` |
| 70 | + // Interfaces is a list of network interfaces to add to the machine. |
| 71 | + Interfaces []Interface `json:"interfaces"` |
| 72 | +} |
| 73 | + |
| 74 | +// Interface is a network interface to add to a machine. |
| 75 | +type Interface struct { |
| 76 | + // Type is the type of the interface. Required. |
| 77 | + Type InterfaceType `json:"type"` |
| 78 | + // NetworkUUID is the UUID of the network to attach the interface to. |
| 79 | + // Can only be set if type is private. |
| 80 | + // Must be compatible with Addresses.SubnetUUID if both are specified. |
| 81 | + NetworkUUID string `json:"networkUUID"` |
| 82 | + // Addresses is an optional list of addresses to assign to the interface. |
| 83 | + // Can only be set if type is private. |
| 84 | + Addresses []Address `json:"addresses"` |
| 85 | +} |
| 86 | + |
| 87 | +// Address is an address to assign to a network interface. |
| 88 | +type Address struct { |
| 89 | + // Address is an optional IP address to assign to the interface. |
| 90 | + Address string `json:"address"` |
| 91 | + // SubnetUUID is the UUID of the subnet to assign the address to. |
| 92 | + // Must be compatible with Interface.NetworkUUID if both are specified. |
| 93 | + SubnetUUID string `json:"subnetUUID"` |
| 94 | +} |
| 95 | + |
| 96 | +// CloudscaleMachineProviderStatus is the type that will be embedded in a Machine.Status.ProviderStatus field. |
| 97 | +// It contains cloudscale-specific status information. |
| 98 | +type CloudscaleMachineProviderStatus struct { |
| 99 | + metav1.TypeMeta `json:",inline"` |
| 100 | + |
| 101 | + // InstanceID is the ID of the instance in Cloudscale. |
| 102 | + // +optional |
| 103 | + InstanceID string `json:"instanceId,omitempty"` |
| 104 | + // Status is the status of the instance in Cloudscale. |
| 105 | + // Can be "changing", "running" or "stopped". |
| 106 | + Status string `json:"status,omitempty"` |
| 107 | + // Conditions is a set of conditions associated with the Machine to indicate |
| 108 | + // errors or other status |
| 109 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 110 | +} |
0 commit comments