### Install Objx Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/stretchr/objx/README.md Install the Objx package using the `go get` command. ```bash go get github.com/stretchr/objx ``` -------------------------------- ### Install go-gitignore Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/monochromegane/go-gitignore/README.md Install the go-gitignore library using the go get command. This command fetches and installs the specified package. ```sh $ go get github.com/monochromegane/go-gitignore ``` -------------------------------- ### Create and Run a Simple SOCKS5 Server Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/armon/go-socks5/README.md This example demonstrates how to create a basic SOCKS5 server with default configuration and start listening for incoming TCP connections on a specified address and port. Ensure the server configuration is set up before starting. ```go // Create a SOCKS5 server conf := &socks5.Config{} server, err := socks5.New(conf) if err != nil { panic(err) } // Create SOCKS5 proxy on localhost port 8000 if err := server.ListenAndServe("tcp", "127.0.0.1:8000"); err != nil { panic(err) } ``` -------------------------------- ### Install and Enable Firewalld Source: https://github.com/openshift/microshift/blob/main/docs/user/howto_firewall.md Installs `firewalld` using `dnf`, enables the service, and starts it immediately. This is a prerequisite for applying firewall rules. ```bash sudo dnf install -y firewalld sudo systemctl enable firewalld --now ``` -------------------------------- ### Create Kickstart File for VM Installation Source: https://github.com/openshift/microshift/blob/main/docs/user/image_mode.md Generates a kickstart file (`kickstart.ks`) for automating the virtual machine installation process, including disk partitioning, network configuration, and container image setup. ```bash cat > kickstart.ks < /etc/crio/openshift-pull-secret <<'EOF' $(cat "${PULL_SECRET}") EOF chmod 600 /etc/crio/openshift-pull-secret %end EOFKS ``` -------------------------------- ### Compile and Run the Dynamic Client Example Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/staging/src/k8s.io/client-go/examples/dynamic-create-update-delete-deployment/README.md Compile the Go program and run it with your kubeconfig. The program will then guide you through creating, updating, listing, and deleting a Deployment. ```bash cd dynamic-create-update-delete-deployment go build -o ./app ``` ```bash ./app # or specify a kubeconfig file with flag ./app -kubeconfig=$HOME/.kube/config ``` -------------------------------- ### Build and Install miekg/dns Source: https://github.com/openshift/microshift/blob/main/vendor/github.com/miekg/dns/README.md Instructions for getting and building the miekg/dns library using Go modules. ```bash go get github.com/miekg/dns go build github.com/miekg/dns ``` -------------------------------- ### Install etcd/client Go Package Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/go.etcd.io/etcd/server/v3/internal/clientv2/README.md Use 'go get' to install the etcd/client library for use with Go modules. ```bash go get go.etcd.io/etcd/v3/client ``` -------------------------------- ### Install blackfriday-tool Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/russross/blackfriday/v2/README.md Download and install the `blackfriday-tool` command-line utility using `go get`. This tool provides a standalone way to process Markdown files. ```go go get github.com/russross/blackfriday-tool ``` -------------------------------- ### Defining a WebService and Route Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/emicklei/go-restful/v3/README.md Example of creating a new WebService, setting its path and content types, and defining a GET route for retrieving a user. ```go ws := new(restful.WebService) ws. Path("/users"). Consumes(restful.MIME_XML, restful.MIME_JSON). Produces(restful.MIME_JSON, restful.MIME_XML) ws.Route(ws.GET("/{user-id}").To(u.findUser). Doc("get a user"). Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")), Writes(User{})) ... func (u UserResource) findUser(request *restful.Request, response *restful.Response) { id := request.PathParameter("user-id") ... } ``` -------------------------------- ### RHEL for Edge Host Example Variables Source: https://github.com/openshift/microshift/blob/main/ansible/README.md Use this for RHEL for Edge images where the host is pre-configured, disabling most setup and installation variables. ```yaml manage_subscription: false rhel_username: rhel_password: rhel_pool_id: manage_repos: false setup_microshift_host: false prometheus_logging: false install_microshift: false build_etcd_binary: false ``` -------------------------------- ### Run systemstat Example Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/bitbucket.org/bertimus9/systemstat/README.md Navigate to the example directory and run the 'go-top.go' example using 'go run'. This requires changing to the first directory in your $GOPATH. ```bash cd to the first directory in your $GOPATH cd src/bitbucket.org/bertimus9/systemstat go run examples/go-top.go ``` -------------------------------- ### Clean Host Example Variables Source: https://github.com/openshift/microshift/blob/main/ansible/README.md Use this configuration for a fresh RHEL host to manage initial setup, subscription, and MicroShift installation. ```yaml manage_subscription: true rhel_username: rhel_password: rhel_pool_id: manage_repos: true setup_microshift_host: true prometheus_logging: true install_microshift: true build_etcd_binary: false ``` -------------------------------- ### Prepare Kickstart File for VM Installation Source: https://github.com/openshift/microshift/blob/main/packaging/imagemode/README.md This section shows how to set variables for user password and pull secrets, and then create a kickstart file ('kickstart.ks') for installing a virtual machine using MicroShift bootc images. It configures disk partitioning, networking, and specifies the ostreecontainer source. ```bash USER_PASSWD= PULL_SECRET=~/.pull-secret.json cat > kickstart.ks < 8080/TCP 13s ``` -------------------------------- ### Build and Run SCTP Example Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/ishidawataru/sctp/README.md Navigate to the example directory, build the application, and then run it as either an SCTP server or client with specified ports and IP addresses. ```bash $ cd example $ go build $ # run example SCTP server $ ./example -server -port 1000 -ip 10.10.0.1,10.20.0.1 $ # run example SCTP client $ ./example -port 1000 -ip 10.10.0.1,10.20.0.1 ``` -------------------------------- ### Enable and start MicroShift Source: https://github.com/openshift/microshift/blob/main/docs/user/howto_test_offline.md Enable MicroShift to start on boot and start it immediately. This command assumes MicroShift is already installed. ```bash systemctl enable --now microshift ``` -------------------------------- ### Initialize IPVS and Get Services (Go) Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/moby/ipvs/README.md Demonstrates how to initialize a new IPVS handle and retrieve a list of existing services. Ensure the necessary permissions are available to communicate with the netlink socket. ```go import ( "log" "github.com/moby/ipvs" ) func main() { handle, err := ipvs.New("") if err != nil { log.Fatalf("ipvs.New: %s", err) } svcs, err := handle.GetServices() if err != nil { log.Fatalf("handle.GetServices: %s", err) } } ``` -------------------------------- ### Install jsonpath Package Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/exponent-io/jsonpath/README.md Use go get to install the jsonpath package. This command fetches and installs the package and its dependencies. ```bash go get -u github.com/exponent-io/jsonpath ``` -------------------------------- ### Create RHEL VM with Kickstart Source: https://github.com/openshift/microshift/blob/main/packaging/kickstart/README.md Use this command to create a RHEL virtual machine. It specifies CPU, memory, disk, network, and uses a kickstart file for automated installation of the OS and MicroShift. Ensure the RHEL boot ISO is in `/var/lib/libvirt/images/` and the kickstart file is in your home directory. ```bash VMNAME=microshift-host NETNAME=default sudo virt-install \ --name ${VMNAME} \ --vcpus 2 \ --memory 2048 \ --disk path=/var/lib/libvirt/images/${VMNAME}.qcow2,size=20 \ --network network=${NETNAME},model=virtio \ --events on_reboot=restart \ --location /var/lib/libvirt/images/rhel-9.4-$(uname -m)-boot.iso \ --initrd-inject "${HOME}/kickstart.ks" \ --extra-args "inst.ks=file://kickstart.ks" \ --wait ``` -------------------------------- ### Install go.yaml.in/yaml/v3 Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/go.yaml.in/yaml/v3/README.md Use 'go get' to install the latest version of the yaml package. ```bash go get go.yaml.in/yaml/v3 ``` -------------------------------- ### Install go.uber.org/atomic Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/go.uber.org/atomic/README.md Install the latest version of the atomic package using go get. ```shell go get -u go.uber.org/atomic@v1 ``` -------------------------------- ### Create Virtual Machine for MicroShift Source: https://github.com/openshift/microshift/blob/main/docs/user/image_mode.md After creating the ISO, copy it to the libvirt images directory and use virt-install to create a virtual machine. The `--initrd-inject` and `--extra-args` are used to provide the kickstart file for automated installation. ```bash VMNAME=microshift-4.18-bootc NETNAME=default sudo cp -Z ./output/bootiso/install.iso /var/lib/libvirt/images/${VMNAME}.iso sudo virt-install \ --name ${VMNAME} \ --vcpus 2 \ --memory 2048 \ --disk path=/var/lib/libvirt/images/${VMNAME}.qcow2,size=20 \ --network network=${NETNAME},model=virtio \ --events on_reboot=restart \ --location /var/lib/libvirt/images/${VMNAME}.iso \ --initrd-inject kickstart.ks \ --extra-args "inst.ks=file://kickstart.ks" \ --wait ``` -------------------------------- ### Install Heredoc Package Source: https://github.com/openshift/microshift/blob/main/etcd/vendor/github.com/MakeNowJust/heredoc/README.md Use 'go get' to install the heredoc package. This command fetches and installs the package into your Go workspace. ```console $ go get github.com/MakeNowJust/heredoc ``` -------------------------------- ### Running the Fake Client Example Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/staging/src/k8s.io/client-go/examples/fake-client/README.md Execute this command to run the fake client example tests. ```go go test -v k8s.io/client-go/examples/fake-client ``` -------------------------------- ### Install uuid Package Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/google/uuid/README.md Use this command to install the uuid package using go get. ```sh go get github.com/google/uuid ``` -------------------------------- ### Create Kickstart File Source: https://github.com/openshift/microshift/blob/main/docs/user/image_mode.md Generates a kickstart file (`kickstart.ks`) for automating the RHEL installation. It configures disk partitioning, user accounts, networking, and includes pre-install and post-install scripts for setting up authentication and pulling the bootc image. ```bash cat > kickstart.ks < /etc/ostree/auth.json <<'EOF' $(cat "${AUTH_CONFIG}") EOF %end # Pull a 'bootc' image from a remote registry ostreecontainer --url "${IMAGE_REF}" %post --log=/dev/console --erroronfail # Create an OpenShift pull secret file cat > /etc/crio/openshift-pull-secret <<'EOF' $(cat "${PULL_SECRET}") EOF chmod 600 /etc/crio/openshift-pull-secret %end EOFKS ``` -------------------------------- ### Install CamelCase Package Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/fatih/camelcase/README.md Use 'go get' to install the camelcase package for your Go project. ```bash go get github.com/fatih/camelcase ``` -------------------------------- ### Install yaml.v3 Package Source: https://github.com/openshift/microshift/blob/main/vendor/gopkg.in/yaml.v3/README.md Use 'go get' to install the yaml.v3 package for use in your Go projects. ```bash go get gopkg.in/yaml.v3 ``` -------------------------------- ### SpdyStream Client Example Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/moby/spdystream/README.md Demonstrates how to establish a SpdyStream connection to a server, create a stream, send data, and receive a response. Requires a running mirroring server on localhost:8080. ```go package main import ( "fmt" "github.com/moby/spdystream" "net" "net/http" ) func main() { conn, err := net.Dial("tcp", "localhost:8080") if err != nil { panic(err) } spdyConn, err := spdystream.NewConnection(conn, false) if err != nil { panic(err) } go spdyConn.Serve(spdystream.NoOpStreamHandler) stream, err := spdyConn.CreateStream(http.Header{}, nil, false) if err != nil { panic(err) } stream.Wait() fmt.Fprint(stream, "Writing to stream") buf := make([]byte, 25) stream.Read(buf) fmt.Println(string(buf)) stream.Close() } ``` -------------------------------- ### Install Kickstart Utilities Source: https://github.com/openshift/microshift/blob/main/packaging/kickstart/README.md Installs necessary utilities for kickstart file creation, specifically openssl for password encryption and gettext for internationalization. ```bash sudo dnf install -y openssl gettext ``` -------------------------------- ### Install and Import YAML Package Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/sigs.k8s.io/yaml/README.md Install the package using go get and import it in your Go projects. ```bash $ go get sigs.k8s.io/yaml ``` ```go import "sigs.k8s.io/yaml" ``` -------------------------------- ### Install bbolt Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/go.etcd.io/bbolt/README.md Install the bbolt library using go get. This updates your go.mod and go.sum files. ```sh $ go get go.etcd.io/bbolt@latest ``` -------------------------------- ### Install multierr Go Package Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/go.uber.org/multierr/README.md Use `go get` to install the latest version of the multierr package. ```bash go get -u go.uber.org/multierr@latest ``` -------------------------------- ### Install and Run Local Go Doc Site Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Use this command to install and run a local Go Doc site for viewing package documentation. ```bash go install golang.org/x/pkgsite/cmd/pkgsite@latest pkgsite ``` -------------------------------- ### Build and Install kubectl Plugin Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/staging/src/k8s.io/sample-cli-plugin/README.md Instructions for building the kubectl plugin binary and placing it in the system's PATH for execution. Assumes a working KUBECONFIG is already set up. ```sh # assumes you have a working KUBECONFIG $ go build cmd/kubectl-ns.go # place the built binary somewhere in your PATH $ cp ./kubectl-ns /usr/local/bin ``` -------------------------------- ### Install treeprint Package Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/xlab/treeprint/README.md Use `go get` to install the treeprint package for use in your Go projects. ```bash $ go get github.com/xlab/treeprint ``` -------------------------------- ### Install systemstat Package Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/bitbucket.org/bertimus9/systemstat/README.md Use 'go get' to install the systemstat package. Ensure your GOPATH is set. ```bash go get bitbucket.org/bertimus9/systemstat ``` -------------------------------- ### Coexisting klog v1 and v2 Example Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/k8s.io/klog/v2/README.md This example demonstrates how to use both klog/v1 and klog/v2 simultaneously within the same project. ```go package main import ( "flag" "k8s.io/klog/v1" "k8s.io/klog/v2" ) func main() { // Initialize klog/v1 flags klogv1.InitFlags(nil) // Initialize klog/v2 flags klogv2.InitFlags(nil) // Use klog/v1 and klog/v2 as needed klogv1.Info("This is a v1 log message") klogv2.Info("This is a v2 log message") // Flush logs before exiting klogv1.Flush() klogv2.Flush() } ``` -------------------------------- ### Install Diskv using Go Get Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/peterbourgon/diskv/README.md Installs the diskv package using the Go build tool. Ensure Go 1 is installed prior to running this command. ```bash $ go get github.com/peterbourgon/diskv ``` -------------------------------- ### Bootstrap MicroShift VM with Kickstart Source: https://context7.com/openshift/microshift/llms.txt Automates the creation of a RHEL virtual machine with MicroShift pre-installed using virt-install and a kickstart file. Ensure the RHEL ISO is available at the specified path. ```bash VMNAME=microshift-starter DVDISO="/var/lib/libvirt/images/rhel-9.4-$(uname -m)-dvd.iso" KICKSTART=https://raw.githubusercontent.com/openshift/microshift/main/docs/config/microshift-starter.ks sudo virt-install \ --name "${VMNAME}" \ --vcpus 2 \ --memory 3072 \ --disk "path=/var/lib/libvirt/images/${VMNAME}.qcow2,size=20" \ --network network=default,model=virtio \ --events on_reboot=restart \ --location "${DVDISO}" \ --extra-args "inst.ks=${KICKSTART}" \ --noautoconsole \ --wait # Get VM IP and access it sudo virsh domifaddr microshift-starter # Login: redhat/redhat ssh redhat@ ``` -------------------------------- ### Install Cobra Library Source: https://github.com/openshift/microshift/blob/main/deps/github.com/openshift/kubernetes/vendor/github.com/spf13/cobra/README.md Use 'go get' to install the latest version of the Cobra library. This command fetches and installs the library, making it available for use in your Go projects. ```bash go get -u github.com/spf13/cobra@latest ```