← Back to Blog

The virtual machine host ( trial two )

The virtual machine host ( trial two ) Candidate for a course for 60 minutes >> CODE >>> reach express and help the audience who struggles with this Objective : Create a virtual machine to configure a kubernetes cluster Key Result: Do it in a infrastructure as Code

The virtual machine host ( trial two )

Candidate for a course for 60 minutes >> CODE >>> reach express and help the audience who struggles with this

Objective : Create a virtual machine to configure a kubernetes cluster

Key Result: Do it in a infrastructure as Code

Key Results: Manage in Azure with Orchestrators Create and Operate

Key Result: Delete and recreate to save the costs

Key Result : Use GPT to do your setup for the syntax

Key Result : Connect to a Linux box which is Kubernetes container friendly

Key Result : Install local xrdp to connect from the local to the cloud

Key Result : Document in a way you can share share

Key Result : learn budgetting in Azure and cost of the resources.

Key Result : Learn to use ssh from local and cloud shell

Key Result : first principles approach test script and add it to the iac

Key Result : OKR and first principles concepts

Key Result : Learning journey with Lacan and Bloom Concepts

Resource Groups > 2

one creater

one is the main

the virtual machine 1

+

the virtual machine 2


the virtual machine 3

Starting Empty

the virtual machine 4

the virtual machine 5

the virtual machine 6

Security group

the virtual machine 7

virtual machine with the ip

the virtual machine 8

Connect with SSH

the virtual machine 9

the virtual machine 10

the virtual machine 11

xrdp script from trial one

network settings

the virtual machine 12

one bash script and shell to run it

the virtual machine 13

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install xrdp
sudo ufw allow 3389/tcp
echo "gnome-session" > ~/.xsession
sudo systemctl restart xrdp

move to bash

the virtual machine 14

the virtual machine 15

better naming

the virtual machine 16

Save commands for

the virtual machine 17

check it out

the virtual machine 18

the virtual machine 19

check it to run it

the virtual machine 20

ask gpt for the command

The error message "Permission denied" indicates that your current user does not have the necessary permissions to execute the script setxrdp.sh. To resolve this issue, you can try the following steps:

  • Check the script permissions: You can use the ls -l command to view the current permissions of the file:

ls -l setxrdp.sh

This will show you the permissions currently set for the file. Look for the execute permission (x) in the output.

  • Make the script executable: If the execute permission is not set for the script, you can add it using the chmod command. This command modifies the file permissions. To make the script executable for the user who owns it, you can run:

chmod u+x setxrdp.sh

This command sets the execute (x) permission for the user (u) who owns the file. If you want to make it executable for all users, replace u+x with a+x.

  • Execute the script with elevated permissions: If the script needs to perform operations that require higher privileges, you might need to run it with sudo (assuming you have sudo privileges):

sudo ./setxrdp.sh

Using sudo executes the script with superuser (administrator) privileges, which may be necessary for tasks like modifying system configurations or installing software.

Try these steps and see if you can execute the script successfully. If you still face issues, there may be other factors at play, such as the script's content or specific system security configurations.

now it starts

the virtual machine 21

the virtual machine 22

why silent runs are important

the virtual machine 23

sudo apt-get update -y``sudo apt-get upgrade -ysudo apt-get install xrdp -y
sudo ufw allow 3389/tcp``echo "gnome-session" > ~/.xsession``sudo systemctl restart xrdp

added -y to the parts that i can

the virtual machine 24

matrix going on as the packages are getting install > get your coffee > check for the networking > network chucks channel great videos

the virtual machine 25

Wrong security group lets check it

the virtual machine 26

Check the last commands

the virtual machine 27

End goal after integrating add it to iac script

Add key results

the virtual machine 28

restart the box

the virtual machine 29

Ask gpt for the error but first connect and fail

the virtual machine 30

the virtual machine 31

the virtual machine 32

the virtual machine 33

add 8080

the virtual machine 34

the virtual machine 35

you need add all to test for the first time

the virtual machine 36

different popup

the virtual machine 37

I can see it gets connected but a black screen

Semblance > Lacan >>> most give up IT due to connection issues

the virtual machine 38

ask gpt and follow the steps

the virtual machine 39

A black screen issue when connecting to a Linux system using RDP and xRDP can stem from various reasons. Here are some troubleshooting steps to help resolve the problem:

  • Check xRDP Service Status: Ensure that the xRDP service is running on your Linux machine. You can check this by running:

sudo systemctl status xrdp

If the service isn't running, start it with:

sudo systemctl start xrdp

  • Verify Desktop Environment Compatibility: xRDP might not work correctly with certain desktop environments. For example, GNOME with Wayland might pose problems. If you are using Ubuntu with GNOME, try installing a different desktop environment that is known to work better with xRDP, such as XFCE:

sudo apt install xfce4

After installing, you'll need to configure xRDP to use XFCE:

echo "startxfce4" > ~/.xsession

Restart the xRDP service:

sudo systemctl restart xrdp

  • Update .xsession File: Ensure your .xsession file in your home directory is configured to start the correct desktop session. You can set this file to start the desktop environment you are using. For example, for XFCE, you would use:

echo xfce4-session > ~/.xsession

  • Adjust RDP Client Settings: Sometimes, settings on the RDP client on your Mac might cause display issues. Check if changing the display settings (such as color depth or resolution) in your RDP client resolves the issue.

  • Review xRDP Logs: Look at the xRDP logs for any errors or warnings that might give you more insight into what's going wrong. You can find the logs here:

sudo cat /var/log/xrdp.log
sudo cat /var/log/xrdp-sesman.log

  • Ensure Proper Network Configuration: Verify that there are no network issues preventing proper communication between your Mac and the Linux server. This includes checking firewalls and network policies.

  • Reinstall xRDP: If all else fails, you might consider uninstalling and then reinstalling xRDP:

sudo apt remove xrdp
sudo apt install xrdp

By following these steps, you should be able to resolve the black screen issue with xRDP on your Linux system. If problems persist, it might be useful to look for specific issues related to the Linux distribution and version you are using, as there might be known issues with certain setups.]]

running it showed

the virtual machine 40

opened up

the virtual machine 41

than volla

the virtual machine 42

now all blue >>> desktop software not loaded to linux

the virtual machine 43

ask gpt and install it

the virtual machine 44

To install a Linux desktop environment on Ubuntu 18.04 for your user interface (UI) usage, you have several options, depending on what kind of experience you're looking for. Below are instructions for installing three popular desktop environments: GNOME, KDE Plasma, and XFCE.

GNOME (Default Desktop for Ubuntu 18.04)

Ubuntu 18.04 comes with GNOME by default. If for some reason GNOME is not installed, or you've removed it and want to reinstall it, you can do so using the following commands:

sudo apt update
sudo apt install ubuntu-desktop

This command installs the full GNOME desktop environment along with the standard Ubuntu applications and optimizations.

KDE Plasma

KDE Plasma is known for its visual appeal and customization options. It offers a more feature-rich and configurable desktop experience. To install KDE Plasma:

sudo apt update
sudo apt install kubuntu-desktop

When you install kubuntu-desktop, you'll be prompted to choose between sddm and lightdm as your display manager. sddm is the default for KDE, and choosing it would typically provide a smoother experience with KDE Plasma.

XFCE

XFCE is a lightweight desktop environment that is fast and uses fewer system resources, making it ideal for older hardware or for users who seek a simple, efficient, and highly customizable desktop environment. To install XFCE:

sudo apt update
sudo apt install xubuntu-desktop

After Installation

After installing any of these desktop environments:

  • Log Out or Reboot: You can either log out or reboot your machine. When you get to the login screen, you might see an option to select your desktop environment.

  • Switch Desktop Environments: If you have multiple desktop environments installed, you can switch between them at the login screen. Look for a session or environment menu on the login screen (usually a small gear icon next to the login button) and select the desktop environment you wish to use.

  • Configure Your Environment: Each desktop environment has its own settings manager where you can customize the appearance and behavior of your desktop, like themes, keyboard shortcuts, and more.

Choose the desktop environment that best suits your needs based on the performance of your system and your personal preferences in terms of usability and appearance.

Install using the ssh

the virtual machine 45

reconnect with saved creadential from mac and windows

the virtual machine 46

first principles the desktop opened up

the virtual machine 47

update your script with the minus y

sudo apt-get update -y
sudo apt-get upgrade -ysudo apt-get install xrdp -y
sudo ufw allow 3389/tcp
echo "gnome-session" > ~/.xsession
sudo install ubuntudesktop -ysudo systemctl restart xrdp

Setup the compute

the virtual machine 48

Check basic apps like youtube

the virtual machine 49

Check cpu and gpu usage

the virtual machine 50

now delete and redo it

missing > the sh file correct network security group

ask gpt and give the script as well ( stop point >>> 1 hour course )

the virtual machine 51

take it from the center > help gpt

the virtual machine 52

get a hold of content size > dont forget we live infinite computing

the virtual machine 53

shows me the place to update

the virtual machine 54

2 of them

the virtual machine 55

the virtual machine 56

getting set at the bottom

the virtual machine 57

update and save

the virtual machine 58

incremental > just update the deployment name to be able to see it

the virtual machine 59

Run the trigger

the virtual machine 60

+

error in workflow

the virtual machine 61

double mention

the virtual machine 62

^^^

Promote an older version

the virtual machine 63

the virtual machine 64

todo > student prerequisities ( 1 hour ) / setup azure

wrong place to update and not updated auto saves

the virtual machine 65

now saved

the virtual machine 66

remove 2 and run

the virtual machine 67

green man is here

the virtual machine 68

incremental deployment much faster

the virtual machine 69

^^^

check config

the virtual machine 70

check the diff > the first principle

rdp rule is in reconnect

the virtual machine 71

the virtual machine 72

ping basic public dns

the virtual machine 73

save the code

{ "definition": { "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", "actions": { "Create_or_update_a_template_deployment": { "inputs": { "body": { "properties": { "mode": "Incremental", "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "adminUsername": { "defaultValue": "rifaterdemsahin", "metadata": { "description": "Specifies a username for the Virtual Machine." }, "type": "string" }, "location": { "defaultValue": "[resourceGroup().location]", "metadata": { "description": "Specifies the location for all resources." }, "type": "string" }, "projectName": { "defaultValue": "oshost", "metadata": { "description": "Specifies a name for generating resource names." }, "type": "string" }, "vmSize": { "defaultValue": "Standard_D2s_v3", "metadata": { "description": "description" }, "type": "string" } }, "resources": [ { "apiVersion": "2020-05-01", "location": "[parameters('location')]", "name": "[variables('networkSecurityGroupName')]", "properties": { "securityRules": [ { "name": "ssh_rule", "properties": { "access": "Allow", "description": "Locks inbound down to ssh default port 22.", "destinationAddressPrefix": "*", "destinationPortRange": "22", "direction": "Inbound", "priority": 123, "protocol": "Tcp", "sourceAddressPrefix": "*", "sourcePortRange": "*" } }, { "name": "RDP_rule", "properties": { "access": "Allow", "description": "Allow RDP access through port 3389.", "destinationAddressPrefix": "*", "destinationPortRange": "3389", "direction": "Inbound", "priority": 124, "protocol": "Tcp", "sourceAddressPrefix": "*", "sourcePortRange": "*" } } ] }, "type": "Microsoft.Network/networkSecurityGroups" }, { "apiVersion": "2020-05-01", "location": "[parameters('location')]", "name": "[variables('publicIPAddressName')]", "properties": { "publicIPAllocationMethod": "Dynamic" }, "sku": { "name": "Basic" }, "type": "Microsoft.Network/publicIPAddresses" }, { "apiVersion": "2020-05-01", "comments": "Simple Network Security Group for subnet [variables('vNetSubnetName')]", "location": "[parameters('location')]", "name": "[variables('networkSecurityGroupName2')]", "properties": { "securityRules": [ { "name": "default-allow-22", "properties": { "access": "Allow", "destinationAddressPrefix": "*", "destinationPortRange": "22", "direction": "Inbound", "priority": 1000, "protocol": "Tcp", "sourceAddressPrefix": "*", "sourcePortRange": "*" } } ] }, "type": "Microsoft.Network/networkSecurityGroups" }, { "apiVersion": "2020-05-01", "dependsOn": [ "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName2'))]" ], "location": "[parameters('location')]", "name": "[variables('vNetName')]", "properties": { "addressSpace": { "addressPrefixes": [ "[variables('vNetAddressPrefixes')]" ] }, "subnets": [ { "name": "[variables('vNetSubnetName')]", "properties": { "addressPrefix": "[variables('vNetSubnetAddressPrefix')]", "networkSecurityGroup": { "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]" } } } ] }, "type": "Microsoft.Network/virtualNetworks" }, { "apiVersion": "2020-05-01", "dependsOn": [ "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]", "[resourceId('Microsoft.Network/virtualNetworks', variables('vNetName'))]", "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]" ], "location": "[parameters('location')]", "name": "[variables('networkInterfaceName')]", "properties": { "ipConfigurations": [ { "name": "ipconfig1", "properties": { "privateIPAllocationMethod": "Dynamic", "publicIPAddress": { "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" }, "subnet": { "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vNetName'), variables('vNetSubnetName'))]" } } } ] }, "type": "Microsoft.Network/networkInterfaces" }, { "apiVersion": "2021-11-01", "dependsOn": [ "[resourceId('Microsoft.Network/networkInterfaces', variables('networkInterfaceName'))]" ], "location": "[parameters('location')]", "name": "[variables('vmName')]", "properties": { "hardwareProfile": { "vmSize": "[parameters('vmSize')]" }, "networkProfile": { "networkInterfaces": [ { "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('networkInterfaceName'))]" } ] }, "osProfile": { "adminPassword": "@{parameters('vmpassword')}", "adminUsername": "[parameters('adminUsername')]", "computerName": "[variables('vmName')]", "linuxConfiguration": { "disablePasswordAuthentication": false } }, "storageProfile": { "imageReference": { "offer": "UbuntuServer", "publisher": "Canonical", "sku": "18_04-lts-gen2", "version": "latest" }, "osDisk": { "createOption": "fromImage" } } }, "type": "Microsoft.Compute/virtualMachines" } ], "variables": { "networkInterfaceName": "[concat(parameters('projectName'), '-nic')]", "networkSecurityGroupName": "[concat(parameters('projectName'), '-nsg')]", "networkSecurityGroupName2": "[concat(variables('vNetSubnetName'), '-nsg')]", "publicIPAddressName": "[concat(parameters('projectName'), '-ip')]", "vNetAddressPrefixes": "10.0.0.0/16", "vNetName": "[concat(parameters('projectName'), '-vnet')]", "vNetSubnetAddressPrefix": "10.0.0.0/24", "vNetSubnetName": "default", "vmName": "[concat(parameters('projectName'), '-vm')]" } } } }, "host": { "connection": { "name": "@parameters('$connections')['arm']['connectionId']" } }, "method": "put", "path": "/subscriptions/@{encodeURIComponent('2cb217c1-366d-41c0-8934-3f82869320d8')}/resourcegroups/@{encodeURIComponent('Openshift')}/providers/Microsoft.Resources/deployments/@{encodeURIComponent('linuxhost2')}", "queries": { "wait": false, "x-ms-api-version": "2016-06-01" } }, "runAfter": {}, "type": "ApiConnection" } }, "contentVersion": "1.0.0.0", "outputs": {}, "parameters": { "$connections": { "defaultValue": {}, "type": "Object" }, "vmpassword": { "defaultValue": "YYmm123!YYmm123!", "type": "String" } }, "triggers": { "manual": { "inputs": { "schema": {} }, "kind": "Http", "type": "Request" } } }, "parameters": { "$connections": { "value": { "arm": { "connectionId": "/subscriptions/2cb217c1-366d-41c0-8934-3f82869320d8/resourceGroups/OpenshiftHelper/providers/Microsoft.Web/connections/arm", "connectionName": "arm", "id": "/subscriptions/2cb217c1-366d-41c0-8934-3f82869320d8/providers/Microsoft.Web/locations/uksouth/managedApis/arm" } } } } }

the virtual machine 74

now make sure the sh automation is added > use incremental for practical checks

Get ideas

the virtual machine 75

To add a shell script that runs during the VM creation in Azure using your provided Logic Apps-based VM deployment template, you'll want to include the shell script in the ARM template section that defines the virtual machine configuration. This is typically done using the customScriptExtension which allows you to execute scripts on the VM after it's been provisioned.

Here’s a step-by-step guide on how to modify your existing template to include a shell script for installing packages:

  • Define the Custom Script Extension in the ARM Template: You will add a new resource to the ARM template that uses the Microsoft.Compute/virtualMachines/extensions type. This extension will run your shell script.

  • Add Your Script: You'll need the script available either in a publicly accessible location (like a GitHub gist or a storage account) or you can directly encode it in the ARM template if it's not too long.

Here's an example of how you might configure the customScriptExtension:

{
"type": "extensions",
"name": "customScriptExtension",
"apiVersion": "2021-11-01",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines', variables('vmName'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.1",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [""] // URL to the shell script you want to execute
},
"protectedSettings": {
"commandToExecute": "bash arguments_if_any"
}
}
}

  • Add the Extension to Your ARM Template:

  • Place the above JSON block into the resources array of the VM definition in your ARM template. Ensure that you replace <URL_to_your_script> and <name_of_your_script.sh> with actual values.

  • The "dependsOn" section should correctly reference the VM resource to ensure that the script runs after the VM is provisioned.

  • Update Any Necessary Parameters and Variables: Make sure that any new parameters or variables you introduce (like URLs or script names) are defined in the parameters or variables section of the template.

  • Deploy the Updated Template: Once the ARM template is updated, deploy it through the same mechanism you usually would (e.g., through the Azure portal, using Azure CLI, or directly from Logic Apps).

If your shell script is intended to configure the VM further or install specific packages, ensure that it contains all the necessary commands to do so and that it's tested in a local or staging environment before being applied to production VMs.

By following these steps, you should be able to integrate a shell script for installing packages into your Azure VM provisioning process using Azure Logic Apps and ARM templates.

Get key part and add it to the helper resource group

the virtual machine 76

Favorites > Storage

the virtual machine 77

the virtual machine 78

Goal keep the helper resource group cost as low as possible

Linux container

the virtual machine 79

download as text and change the extension

the virtual machine 80

the virtual machine 81

upload and get the link

the virtual machine 82

SAS URL genereate

the virtual machine 83

the virtual machine 84

https:&#047;&#047;scritpts.blob.core.windows.net/linux/xrdpsetup.sh?sp=r&st=2024-04-14T10:56:09Z&se=2029-04-14T18:56:09Z&spr=https&sv=2022-11-02&sr=b&sig=eIBoiRyT4m0xUJCHI%2BdZbGKcqzNfn7VUHXIDpxifESc%3D

ask gpt to add it

the virtual machine 85

{ "type": "extensions", "name": "customScriptExtension", "apiVersion": "2021-11-01", "location": "&#091;parameters('location')]", "dependsOn": &#091; "&#091;resourceId('Microsoft.Compute/virtualMachines', variables('vmName'))]" ], "properties": { "publisher": "Microsoft.Azure.Extensions", "type": "CustomScript", "typeHandlerVersion": "2.1", "autoUpgradeMinorVersion": true, "settings": { "fileUris": &#091; "https://scritpts.blob.core.windows.net/linux/xrdpsetup.sh?sp=r&st=2024-04-14T10:56:09Z&se=2029-04-14T18:56:09Z&spr=https&sv=2022-11-02&sr=b&sig=eIBoiRyT4m0xUJCHI%2BdZbGKcqzNfn7VUHXIDpxifESc%3D" ] }, "protectedSettings": { "commandToExecute": "bash xrdpsetup.sh" } } }

URL for the sh> https://docs.google.com/document/d/1AzbSs5pvMs7MZUDctIH3r-o_Ha_XBs68MfhCeAhUvQI/edit?usp=sharing

Easier to add to the top with the comma

the virtual machine 86

make it thelinuxhost4withscript more understandtable

and run leave breadcrumbs

the virtual machine 87

vm name can be wrong the depends on

the virtual machine 88

the virtual machine 89

as it is on the top easier to find > and update [concat(parameters('projectName'), '-vm')]

update

the virtual machine 90

name in multiple places

the virtual machine 91

add new version

the virtual machine 92

syntax error

the virtual machine 93

ask gpt > not one error multiple errors

the virtual machine 94

save and rerun

the virtual machine 95

see the green

the virtual machine 96

check incremental deployments

the virtual machine 97

now destroy manually dont wait 3 days

you can always rename better by cloning

the virtual machine 98

renamed

the virtual machine 99

createresourcegroup to deletecreateresourcegroup

remove the old one

Get better at symbols every time

the virtual machine 100

Breadcrumbs for yourself

the virtual machine 101

Deletion takes time > get coffee and you can not connect

the virtual machine 102

Cleaned up

the virtual machine 103

Rerun > this can be also createupdate host

the virtual machine 104

Coming in

the virtual machine 105

Check the new ip

the virtual machine 106

52.151.91.57

edit in remote desktop

the virtual machine 107

initial connection makes you wait as the system needs to reboot

add reboot at the end

add to sh file make it richer

the virtual machine 108

edit script with what you learned

the virtual machine 109

^^^Save it

the virtual machine 110

GPT improve the script and read it

the virtual machine 111

Much richer and more to learn

the virtual machine 112

Before copy paste

the virtual machine 113

Read with gpt

the virtual machine 114

the virtual machine 115

the virtual machine 116

Added logging that we desperately wanted

the virtual machine 117

Manual restart is there

the virtual machine 118

Check activity log for cloud logs

the virtual machine 119

Black screen problem is back > the desktop might not be installed

firewall and xrdp is there but not ui

the virtual machine 120

Go to zero point and retry and now you know the code gets triggered

the virtual machine 121

have detailed logs > after deletion it would be much harder

the virtual machine 122

unique resources takes longer time to delete and can get locked! >> shared infra and names!

the virtual machine 123

Refresh would show them going out

the virtual machine 124

update this

the virtual machine 125

the virtual machine 126

not that fast

the virtual machine 127

use gpt

the virtual machine 128

the virtual machine 129

generic and auto update

the virtual machine 130

Green light check seconds and colors

the virtual machine 131

Better naming coming on

the virtual machine 132

more transactional customextensions is taking a longer time

the virtual machine 133

Let it finish and time it

the virtual machine 134

8minutes

the virtual machine 135

the virtual machine 136

Add a library becomes another task

update the operating system is another task

the virtual machine 137

Thanks for joining the training hope the pain of creating a linux vm in the cloud with automation and connecting with the ui is solved. Meet you in the next exercise.

Moving to express it

the virtual machine 138

References >

^^^

https://rifaterdemsahin.com/2024/04/09/openshift-is-back


Imported from rifaterdemsahin.com · 2024